// @flow
// Plagiarized from http://blog.krawaller.se/posts/explaining-callbags-via-typescript-definitions/
// and added generics.
export type START = 0
export type DATA = 1
export type END = 2
export type SourceTalkback = ((request: DATA) => void) &
((terminate: END) => void)
export type SinkTalkback = ((
start: START,
sourceTalkback: SourceTalkback
) => void) &
((deliver: DATA, data: T) => void) &
((terminate: END, error?: any) => void)
export type SourceInitiator = (type: START, payload: SinkTalkback) => void
export type SinkConnector = (
source: SourceInitiator
) => SourceInitiator | void
export type SourceFactory = (...args: any[]) => SourceInitiator
export type Operator = (...args: any[]) => SinkConnector
export type Callbag =
| SourceTalkback
| SinkTalkback<>
| SourceFactory<>
| SourceInitiator<>
| SinkConnector<>