@cycle/state
Version:
Wraps your Cycle.js main function with reducer-driven state management
27 lines (26 loc) • 1.24 kB
TypeScript
import { Stream, MemoryStream } from 'xstream';
import { Scope, Reducer } from './types';
export declare function isolateSource<T, R>(source: StateSource<T>, scope: Scope<T, R>): StateSource<R>;
export declare function isolateSink<T, R>(innerReducer$: Stream<Reducer<R>>, scope: Scope<T, R>): Stream<Reducer<T>>;
/**
* Represents a piece of application state dynamically changing over time.
*/
export declare class StateSource<S> {
stream: MemoryStream<S>;
private _stream;
private _name;
constructor(stream: Stream<any>, name: string);
/**
* Selects a part (or scope) of the state object and returns a new StateSource
* dynamically representing that selected part of the state.
*
* @param {string|number|lens} scope as a string, this argument represents the
* property you want to select from the state object. As a number, this
* represents the array index you want to select from the state array. As a
* lens object (an object with get() and set()), this argument represents any
* custom way of selecting something from the state object.
*/
select<R>(scope: Scope<S, R>): StateSource<R>;
isolateSource: typeof isolateSource;
isolateSink: typeof isolateSink;
}