@parity/light.js-react
Version:
A HOC to easily use @parity/light.js with React.
30 lines (29 loc) • 1.03 kB
TypeScript
/// <reference types="recompose" />
import { RpcObservable } from '@parity/light.js';
interface Observables {
[key: string]: RpcObservable<any, any>;
}
/**
* HOC which listens to one Observable, and update the React wrapped component
* every time the Observable fires.
*
* @param key - The key to add the value in `this.props`, so that the value
* will be accessible via `this.props[key]`.
* @param rpc$ - The RpcObservable to listen to.
*/
export declare const withOneObservable: <OwnProps, T>(
key: string,
rpc$: RpcObservable<any, T>
) => import('recompose').ComponentEnhancer<unknown, unknown>;
/**
* HOC which listens to multiple Observables, and injects those emitted values
* into `this.props`.
*
* @param observables - An object where the keys will be injected into
* `this.props`, and the value of each key will be the value emitted by the
* corresponding Observable.
*/
declare const light: (
observables: Observables
) => import('recompose').ComponentEnhancer<unknown, unknown>;
export default light;