-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Emitter of a healthy mind #267
Comments
Hi ! Could I complete this issue ? |
Yes, this is just a draft, it might be useful, but it needs some work, maybe the contracts are not convenient, maybe the implementation can be optimized, more tests, use cases, docs, etc. |
@GoodLuckMister You can do that |
Example 1: const ee = new Emitter();
for await (const chunk of ee.toIterator('chunk')) {
console.log({ chunk });
} Example 2: const ee = new Emitter();
const readable = Readable.from(ee);
readable.pipe(target); |
@GoodLuckMister @serrhiy I'd prefer you will work together. Please rename our EventEmitter to Emitter to emplasis its alternative implementation and incompatibility while stay close related abstraction. |
@GoodLuckMister @serrhiy Please note than we move from multiple arguments in event |
@GoodLuckMister email me (listed in my profile) so we can coordinate actions |
const emitExpect = ['await emit 1', 'await emit 2', 'await emit 3']; emitExpect.forEach((e) => ee.on('name5', () => e)); const emitResult = await ee.emit('name5'); assert.deepStrictEqual(emitResult, emitExpect); Emmiter's 'emit' methos does not return value and resolves when all async functions finish. metarhia#267
Iteration example:
ee.toAsyncIterable('user')
will return new AsyncIterable('user')asyncIterable[Symbol.asyncIterator]
will returnAsyncIterator
asyncIterator.next
will returnAsyncIteratorStep { done, value }
The text was updated successfully, but these errors were encountered: