import * as React from 'react'; import { Store } from 'redux'; import { Effect, FxState, FxSlice, FxActionCreators, FxActionsConfig } from 'fx-state'; import { Renderable, Omit } from './types'; declare type CallableEffectChildren = (state: FxState, call: (...params: Params) => void) => Renderable; export interface CallableEffectProps { effect: Effect | FxActionsConfig; children: CallableEffectChildren; store?: Store; } /** * CallableEffect is a React render-prop component that injects FxState for any side effect into its children. * It gives the consumer control over when the side-effect is executed. * This can be used for user-initiated side-effect calls, such as submitting a search or deleting a record. * Each instance of a CallableEffect will own its own unique FxState and FxActions. * On unmount, the component will destroy its FxState, cleaning up after itself. * * The following example initiates the given side-effect when the button is clicked. * While it is pending, it renders a loading indicator. * When it resolves, it renders the value that was passed to `resolve()`. * If the Promise is rejected, it renders the error that was passed to `reject()`. * * @example * ``` * // typeof effect: (p1: number, p2: string) => Promise * * * {(state, call) => *
* {state.error ? {state.error} * : state.data ? {state.data} : state.status === 'active' && } * *
} *
* ``` */ export declare class CallableEffect extends React.Component> { fxActions: FxActionCreators; constructor(props: CallableEffectProps); render(): JSX.Element; } /** * ContextCallableEffect is identical to CallableEffect, except that it uses StoreConsumer to pull the `store` prop off of Legacy React Context. */ export declare class ContextCallableEffect extends React.Component, 'store'>> { render(): JSX.Element; } export {};