Skip to content

Commit a9fc693

Browse files
committed
feat: add Subject<A, B> type
1 parent a6d1c37 commit a9fc693

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/create.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { AttachSink } from './types'
21
import { ProxyStream } from './ProxyStream'
32
import { Stream } from '@most/types'
3+
import { Subject } from './types'
44
import { id } from '@most/prelude'
55

6-
export function create<A = any>(): [AttachSink<A>, Stream<A>]
7-
export function create<A, B>(f: (stream: Stream<A>) => B): [AttachSink<A>, B]
6+
export function create<A = any>(): Subject<A, A>
7+
export function create<A, B>(f: (stream: Stream<A>) => Stream<B>): Subject<A, B>
88

99
export function create<A, B = A>(
1010
f: (stream: Stream<A>) => Stream<B> = id as (stream: Stream<A>) => Stream<B>
11-
): [AttachSink<A>, Stream<B>] {
11+
): Subject<A, B> {
1212
const source = new ProxyStream<A>()
1313

1414
return [source, f(source)]

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Sink, Stream } from '@most/types'
22

3+
export type Subject<A, B> = [Sink<A>, Stream<B>]
4+
35
export interface AttachSink<A> extends Sink<A> {
46
attach(source: Stream<A>): Stream<A>
57
}

0 commit comments

Comments
 (0)