Skip to content

Commit

Permalink
feat: add Subject<A, B> type
Browse files Browse the repository at this point in the history
  • Loading branch information
TylorS committed Sep 25, 2017
1 parent a6d1c37 commit a9fc693
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/create.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { AttachSink } from './types'
import { ProxyStream } from './ProxyStream'
import { Stream } from '@most/types'
import { Subject } from './types'
import { id } from '@most/prelude'

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

export function create<A, B = A>(
f: (stream: Stream<A>) => Stream<B> = id as (stream: Stream<A>) => Stream<B>
): [AttachSink<A>, Stream<B>] {
): Subject<A, B> {
const source = new ProxyStream<A>()

return [source, f(source)]
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Sink, Stream } from '@most/types'

export type Subject<A, B> = [Sink<A>, Stream<B>]

export interface AttachSink<A> extends Sink<A> {
attach(source: Stream<A>): Stream<A>
}

0 comments on commit a9fc693

Please sign in to comment.