-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathinterfaces.ts
70 lines (56 loc) · 1.66 KB
/
interfaces.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import * as React from 'react'
import { Stream, Subject, Subscription } from './xs'
import { $ } from './fantasy/typeclasses'
import * as PropTypes from 'prop-types';
export const XREACT_ENGINE = '@reactive-react/xreact.engine';
export interface Actions<T> {
[propName: string]: (...v: any[]) => T
}
export interface Plan<E extends Stream, I, S> {
(intent: Subject<E, I>, props?: Xprops<I>): Machine<E, I, S>
}
export interface Update<S> {
(current: S): Partial<S>
}
export interface Machine<E extends Stream, I, S> {
actions?: Actions<I>,
update$: $<E, Update<S>>
}
export interface ConfiguredMachine<E extends Stream, S> {
actions?: Actions<void>,
update$: $<E, Update<S>>
}
export interface Xprops<I> {
actions?: Actions<I>
history?: boolean
[propName: string]: any;
}
export class Xcomponent<E extends Stream, I, S> extends React.PureComponent<Xprops<I>, S> {
machine: ConfiguredMachine<E, S>
subscription: Subscription
context: ContextEngine<E, I, S>
}
export interface XcomponentClass<E extends Stream, I, S> {
displayName: string
contextTypes?: ContextType<E, I, S>
defaultProps?: any
new(props: Xprops<I>, context: ContextEngine<E, I, S>): Xcomponent<E, I, S>;
}
export interface History<E extends Stream, S> {
path: Subject<E, (n: number) => number>
history: $<E, S>
}
export interface Stamp<S> {
value: S
time: number
}
export interface Engine<E extends Stream, I, S> {
intent$: Subject<E, I>
history$: Subject<E, S>
}
export interface ContextEngine<E extends Stream, I, H> {
[name: string]: Engine<E, I, H>
}
export interface ContextType<E extends Stream, I, H> {
[name: string]: PropTypes.Requireable<Engine<E, I, H>>
}