remote-controlled-promise
Version:
Create a Promise object that is controllable from outside
36 lines (23 loc) • 576 B
Markdown
object that is controllable from outside
* Node.js ≥ 8.9.0
```javascript
import {create} from 'remote-controlled-promise'
// Create a controlled promise
const ctrl = create()
// `ctrl.promise` is a that controlled promise
ctrl.promise.then(value => console.log(`resolved ${value}`))
console.log('foo')
ctrl.resolve(1234)
console.log('bar')
```
This will print:
```
foo
bar
resolved 1234
```
[ ](https://git.io/vhaEz) © [Hoàng Văn Khải](https://github.com/KSXGitHub)
Create a Promise