-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace iterall with native Symbol.asyncIterator + fix return t…
…ypes (#232) * fix(typings): return AsyncIterableIterator instead of AsyncIterator BREAKING fixes the type annotation of the abstract class PubSubEngine. According to the TypeScript type-defintion a `PubSubAsyncIterator` instance is actually a `AsyncIterableIterator` instead of an `AsyncIterator`. The typing of `PubSubAsyncIterator` is way more convenient as it allows iterating over it with the `for await (const foo of iterator) { doSth() }` syntax, which is super handy for filtering or mapping (See https://gist.github.com/n1ru4l/127178705cc0942cad0e45d425e2eb63 for some example operators). * remove iterall * rename asyncIterator method to asyncIterableIterator. * Slight tweaks based on graphql-js 16 changes * Changelog update Co-authored-by: hwillson <hugh@octonary.com>
- Loading branch information
Showing
7 changed files
with
49 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import {PubSubAsyncIterator} from './pubsub-async-iterator'; | ||
import {PubSubAsyncIterableIterator} from './pubsub-async-iterable-iterator'; | ||
|
||
export abstract class PubSubEngine { | ||
public abstract publish(triggerName: string, payload: any): Promise<void>; | ||
public abstract subscribe(triggerName: string, onMessage: Function, options: Object): Promise<number>; | ||
public abstract unsubscribe(subId: number); | ||
public asyncIterator<T>(triggers: string | string[]): AsyncIterator<T> { | ||
return new PubSubAsyncIterator<T>(this, triggers); | ||
public asyncIterableIterator<T>(triggers: string | string[]): PubSubAsyncIterableIterator<T> { | ||
return new PubSubAsyncIterableIterator<T>(this, triggers); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters