JSPM

ember-runloop-decorators

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q13220F
  • License MIT

Decorators for `@ember/runloop`

Package Exports

  • ember-runloop-decorators

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ember-runloop-decorators) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.
  }
}