Giter Club home page Giter Club logo

ember-runloop-decorators's Introduction

ember-runloop-decorators

CI npm version Download Total Ember Observer Score code style: prettier dependencies devDependencies

Decorators for @ember/runloop.

Installation

ember install ember-runloop-decorators

Usage

@inRunLoop

class Foo {
  @inRunLoop
  runInRunLoop() {
    // If no run-loop is present, it creates a new one. If a run loop is
    // present, it will queue itself to run on the existing run-loop's
    // `actions` queue.
  }
}

@joinRunLoop

class Foo {
  @joinRunLoop
  runInRunLoop() {
    // If no run-loop is present, it creates a new one. If a run loop is
    // present, it will queue itself to run on the existing run-loop's
    // `actions` queue.
  }
}

@bind

class Foo {
  @bind
  onActionsQueue() {
    // This will be executed in the `actions` queue.
  }
 *
  @bind('sync')
  onActionsQueue() {
    // This will be executed in the `sync` queue.
  }
}

@schedule

class Foo {
  @schedule
  onActionsQueue() {
    // This will be executed in the `actions` queue.
  }
 *
  @schedule('sync')
  onActionsQueue() {
    // This will be executed in the `sync` queue.
  }
}

@scheduleOnce

class Foo {
  @schedule
  onActionsQueue() {
    // This will be executed in the `actions` queue.
  }
 *
  @schedule('sync')
  onActionsQueue() {
    // This will be executed in the `sync` queue.
  }
}

@once

class Foo {
  @once
  onceInCurrentRunLoop() {
    // If no run-loop is present, it creates a new one. If a run loop is
    // present, it will queue itself to run on the existing run-loop's
    // `actions` queue.
  }
}

@later

class Foo {
  @later(100)
  after100ms() {
    // Delay calling the method until the wait period has elapsed.
    // Additional calls enqueue additional executions.
  }
}

@next

class Foo {
  @next
  inRunLoop() {
    // If no run-loop is present, it creates a new one. If a run loop is
    // present, it will queue itself to run on the existing run-loops action
    // queue.
  }
}

@debounce

class Foo {
  @debounce(100)
  after100ms() {
    // Delay calling the method until the debounce period has elapsed with
    // no additional calls. If called again before the specified time has
    // elapsed, the timer is reset and the entire period must pass again
    // before the method is called.
  }
 *
  @debounce(100, true)
  immediatelyAndAfter100ms() {
    // Run the method immediately, but debounce other calls for this method
    // until the wait time has elapsed. If called again before the specified
    // time has elapsed, the timer is reset and the entire period must pass
    // again before the method can be called again.
  }
}

@throttle

class Foo {
  @throttle(100)
  every100ms() {
    // Ensure that the method is never called more frequently than the
    // specified spacing period. The method is called immediately.
  }
 *
  @debounce(100, false)
  delayedByAndEvery100ms() {
    // Ensure that the method is never called more frequently than the
    // specified spacing period. The method is called after the first spacing
    // period has elapsed.
  }
}

ember-runloop-decorators's People

Contributors

buschtoens avatar ember-tomster avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.