refract-xstream
Version:
Refract bindings for React with xstream: harness the power of reactive programming to supercharge your components!
58 lines (57 loc) • 1.7 kB
TypeScript
import { Stream, Listener, Subscription } from 'xstream'
import { PushEvent } from './baseTypes'
export { Listener, Subscription }
export interface UseEvent {
(eventName: string): [Stream<void>, () => any]
<Type = any>(eventName: string, seedValue?: Type): [
Stream<Type>,
(val: Type) => any
]
}
export interface FromEvent {
(eventName: string): Stream<void>
<Type>(eventName: string, valueTransformer?: (val: any) => Type): Stream<
Type
>
}
export interface ObservableComponentBase {
mount: Stream<any>
unmount: Stream<any>
fromEvent: FromEvent
pushEvent: PushEvent
useEvent: UseEvent
}
export interface Observe {
observe: <Type>(
propName?: string,
valueTransformer?: (val: any) => Type
) => Stream<Type>
}
export declare type ObservableComponent = Observe & ObservableComponentBase
export declare type Aperture<Props, Effect, Context = any> = (
component: ObservableComponent,
initialProps: Props,
initialContext?: Context
) => Stream<Effect>
export declare const subscribeToSink: <Type>(
sink: Stream<Type>,
next: (val: Type) => void,
error?: (error: any) => void
) => Subscription
export declare const getObserve: <Props>(
getProp: any,
data: any,
decoratedProps: any
) => <Type>(propName?: any, valueTransformer?: any) => any
export declare const createComponent: <Props>(
getProp: any,
dataObservable: any,
pushEvent: PushEvent,
decoratedProps: boolean
) => ObservableComponent
export declare const createObservable: (
subscribe: any
) => {
[x: string]: any
subscribe: any
}