Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/erikras/callbag-types
Types for 👜 Callbags
https://github.com/erikras/callbag-types
callbag callbags flow observable types typescript
Last synced: about 1 month ago
JSON representation
Types for 👜 Callbags
- Host: GitHub
- URL: https://github.com/erikras/callbag-types
- Owner: erikras
- License: mit
- Created: 2018-06-12T21:55:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-13T12:31:22.000Z (over 6 years ago)
- Last Synced: 2024-09-16T12:45:00.423Z (about 2 months ago)
- Topics: callbag, callbags, flow, observable, types, typescript
- Language: JavaScript
- Size: 19.5 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.js
- License: LICENSE
Awesome Lists containing this project
README
/**
* *****************************************************************
* *****************************************************************
* ⚠️ 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.
* *****************************************************************
* *****************************************************************
*
* This library provides types for 👜 Callbags according to the spec.
*
* Spec: https://github.com/callbag/callbag
* Original Typing work: http://blog.krawaller.se/posts/explaining-callbags-via-typescript-definitions/
*
* Installation
*
* npm install --save-dev callbag-types
*
* Usage
*
* import type { START, SourceInitiator } from 'callbag-types'
*
* @flow
*/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) => voidexport type SinkConnector = (
source: SourceInitiator
) => ?SourceInitiatorexport type SourceFactory = (...args: any[]) => SourceInitiator
export type Operator = (...args: any[]) => SinkConnector
export type Callbag =
| SourceTalkback<*>
| SinkTalkback<*>
| SourceFactory<*>
| SourceInitiator<*>
| SinkConnector<*>