@shopify/deferred
A new promise along with methods to change its state.
Last updated 3 months ago by shopify-dep .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @shopify/deferred 
SYNC missed versions from official npm registry.

@shopify/deferred

A new promise along with methods to change its state.

Installation

$ yarn add @shopify/deferred

Usage

import {Deferred} from '@shopify/deferred';

const deferred = new Deferred();
await deferred.promise;

Resolving with a value:

import {Deferred} from '@shopify/deferred';

const deferred = new Deferred();
deferred.resolve(5);

const five = await deferred.promise;

Promise vs. deferred

A deferred has a promise which functions as a proxy for the future result. While a promise is a value returned by an asynchronous function, a deferred can be resolved or rejected by it's caller which separates the promise from the resolver.

Current Tags

  • 0.1.4                                ...           latest (3 months ago)

1 Versions

  • 0.1.4                                ...           3 months ago
Downloads
Today 0
This Week 1
This Month 2
Last Day 0
Last Week 0
Last Month 2
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |