@cowprotocol/cow-sdk
Version:
<p align="center"> <img width="400" src="https://github.com/cowprotocol/cow-sdk/raw/main/docs/images/CoW.png" /> </p>
53 lines (35 loc) • 1.2 kB
Markdown
[![NPM Package][npm-image]][npm-url]
This is a sub-package of [web3.js][repo].
This is the PromiEvent package used to return a EventEmitter mixed with a Promise to allow multiple final states as well as chaining.
Please read the [documentation][docs] for more.
You can install the package either using [NPM](https://www.npmjs.com/package/web3-core-promievent) or using [Yarn](https://yarnpkg.com/package/web3-core-promievent)
```bash
npm install web3-core-promievent
```
```bash
yarn add web3-core-promievent
```
```js
const Web3PromiEvent = require('web3-core-promievent');
const myFunc = function(){
const promiEvent = Web3PromiEvent();
setTimeout(function() {
promiEvent.eventEmitter.emit('done', 'Hello!');
promiEvent.resolve('Hello!');
}, 10);
return promiEvent.eventEmitter;
};
// and run it
myFunc()
.on('done', console.log)
.then(console.log);
```
[]: http://web3js.readthedocs.io/en/1.0/
[]: https://github.com/ethereum/web3.js
[]: https://img.shields.io/npm/v/web3-core-promievent.svg
[]: https://npmjs.org/package/web3-core-promievent