0.2.2 • Published 5 years ago
my-async-store v0.2.2
my-async-store
Introduction
There is a case that we have many asynchronous functions need to call, and they are probably in different files.
And we need to know the state of them.
That's a little trouble and this library make it simplify.
Install
Install either in node or browser as you like.
npm i -D 'my-async-store'
or
yarn add -D 'my-async-store'
or
<script src="./dist/my-async-store.umd.js"></script>
Usage
in node:
const { set, wait } = require('my-async-store')
or
import { set, wait } from 'my-async-store'
or in browser:
const { set, wait } = MyAsyncStore
Then
// foo.js
setTimeout(() => {
console.log('foo is ready')
set('foo')
}, 10)
// bar.js
setTimeout(() => {
console.log('bar is ready')
set('bar')
}, 20)
// hello.js
wait('foo', 'bar').then(() => console.log('everyone is ready!'))
and console will logs
// foo is ready
// bar is ready
// everyone is ready!
That's all!
Documentation
Further usage see API documentation.
Changelog see Changelog.
And here is the recap of Internal Implementation.