0.0.2 • Published 6 years ago

callbag-types v0.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

/**



  •                   ⚠️  DO NOT USE! ⚠️
  • From what I can tell, Flow does not allow enough fine control
  • over polymorphism to realistically tame the possible typings
  • of callbags. If someone can figure it out, PRs very, very welcome.


*

export type START = 0 export type DATA = 1 export type END = 2

/**

  • Quoth the spec:
  • "A callbag is terminated when the first argument is 2 and the second
  • argument is either undefined (signalling termination due to success)
  • or any truthy value (signalling termination due to failure)." */ export type SourceTalkback = ((DATA, T) => void) & ((END, error?: any) => void)

export type SinkTalkback = (( START, SourceTalkback | SourceInitiator ) => void) & SourceTalkback

/**

  • Quoth the spec:
  • "When a source is greeted and given a sink as payload, the sink MUST
  • be greeted back with a callbag payload that is either the source
  • itself or another callbag (known as the 'talkback'). In other
  • words, greets are mutual. Reciprocal greeting is called a handshake." */ export type SourceInitiator = (START, SinkTalkback) => void

export type SinkConnector = ( source: SourceInitiator ) => ?SourceInitiator

export type SourceFactory = (...args: any[]) => SourceInitiator

export type Operator = (...args: any[]) => SinkConnector

export type Callbag = | SourceTalkback<> | SinkTalkback<> | SourceFactory<> | SourceInitiator<> | SinkConnector<*>

0.0.2

6 years ago

0.0.1

6 years ago