Skip to content

Commit

Permalink
Add IStream interface
Browse files Browse the repository at this point in the history
  • Loading branch information
afshin committed Nov 8, 2022
1 parent dd323c4 commit 91af63a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions packages/signaling/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ export interface ISignal<T, U> {
disconnect(slot: Slot<T, U>, thisArg?: any): boolean;
}

/**
* An object that is both a signal and an async iterable iterator.
*/
export interface IStream<T, U>
extends ISignal<T, U>,
AsyncIterableIterator<U> {}

/**
* A concrete implementation of `ISignal`.
*
Expand Down Expand Up @@ -345,10 +352,7 @@ export namespace Signal {
/**
* A stream with the characteristics of a signal and an async iterator.
*/
export class Stream<T, U>
extends Signal<T, U>
implements AsyncIterableIterator<U>
{
export class Stream<T, U> extends Signal<T, U> implements IStream<T, U> {
/**
* Return an async iterator that yields every emission.
*/
Expand Down
6 changes: 5 additions & 1 deletion review/api/signaling.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export interface ISignal<T, U> {
disconnect(slot: Slot<T, U>, thisArg?: any): boolean;
}

// @public
export interface IStream<T, U> extends ISignal<T, U>, AsyncIterableIterator<U> {
}

// @public
export class Signal<T, U> implements ISignal<T, U> {
constructor(sender: T);
Expand Down Expand Up @@ -41,7 +45,7 @@ export namespace Signal {
export type Slot<T, U> = (sender: T, args: U) => void;

// @public
export class Stream<T, U> extends Signal<T, U> implements AsyncIterableIterator<U> {
export class Stream<T, U> extends Signal<T, U> implements IStream<T, U> {
[Symbol.asyncIterator](): AsyncIterableIterator<U>;
emit(args: U): void;
next(): Promise<IteratorResult<U>>;
Expand Down

0 comments on commit 91af63a

Please sign in to comment.