New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ember-run-callback

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-run-callback

The default blueprint for ember-cli addons.

latest
npmnpm
Version
0.0.0
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

ember-run-callback

Provides callback(), which lets you easily write runloop and test aware async code:

Ember.Component.extend({
  actions: {

    addCreditCard(card) {
      Stripe.addCard(card, callback(() => {
        this.transitionTo('index');
      }));
    }

  }
});

Now, in your tests, you can:

click('.add-credit-card');
andThen(function() {
  assert(currentRouteName() === 'index');
});

The callback() method takes the function which you want to be able to run asynchronously, and returns a wrapped function you can use in it's place.

When you invoke callback(), it will notify Ember that some async activity is taking place (via registerWaiter) so your tests will wait for that activity to complete.

When the returned wrapper function is eventually called, it will call your original function (wrapped in an Ember.run()) call, and notify Ember that this particular async activity has finished.

NOTE: When you invoke callback() to get your wrapper function, Ember is immediately notified of an async activity. This means that if you never call the wrapper function that is returned, Ember will never be notified that the async activity ended, and your tests will hang.

If you need to abort the callback, you can use the supplied cancel() method and pass in the wrapper function you got from callback():

import callback, { cancel } from 'ember-run-callback';

let wrapper = callback(function() { /* ... */ }));
cancel(wrapper);

See the related RFC for details and the motivation.

Keywords

ember-addon

FAQs

Package last updated on 29 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts