UNPKG

raiden-ts

Version:

Raiden Light Client Typescript/Javascript SDK

27 lines (26 loc) 1.42 kB
/** * This file introduces a 'persister' middleware for redux * * It's coupled with RaidenDatabase, and runs a root _reducer-like_ function for each action/state * change going through redux state machine. * The function receives the RaidenDatabase instance, a tuple containing the current and previous * state, and the action which triggered this change. Like reducers, the function **must not** * change state, but in this case, return value is also ignored. Instead, it should do whatever * logic it needs to persist the new state on the database. Redux-state changes should still be * performed on reducers, as usual. * This is useful as a reducer-like synchronous function for members of the state which aren't * kept in the state, but on the database instead, or to sync/persist state changes to the * database storage. */ import type { Dispatch, Middleware } from 'redux'; import type { RaidenAction } from './actions'; import type { RaidenDatabase } from './db/types'; import type { RaidenState } from './state'; /** * Create a raiden persister middleware for redux. * The persister will delta states before and after an action, and persist values in database. * * @param db - Raiden Database object * @returns Middleware function to be applied to redux */ export declare function createPersisterMiddleware(db: RaidenDatabase): Middleware<undefined, RaidenState, Dispatch<RaidenAction>>;