Web3 Redux Middleware
PromiEvent-redux Middleware enables declarative reducers when making calls to the Ethereum network with Web3 Redux: it accepts a promiEvent or promise and dispatches pending, hashed, confirmed, receipt, fulfilled and rejected actions.
Heavily inspired by the popular redux-promise-middleware library.
Example
const store = ; const EXAMPLE = 'EXAMPLE'; const contract = abi; // To Use just attach a PromiEvent as a payload const promiEventActionCreator = type: EXAMPLE payload: contract methods ; // The middleware will intercept the action and dispatch actions as the network events occur { // A _PENDING event will be sent right away }; // Alternatively you can attatch the promise to a promiEvent to the promiEvent property// Common use case is when you want to send some data for optimistic loading// The data will be dispatched on the _PENDING actionconst promiEventAction2 = type: EXAMPLE payload: data: 'Some Data' promiEvent: contract methods ); // Any meta data can be attatched the the meta property. It will be dispatched on every eventconst promiEventAction3 = type: EXAMPLE meta: 'some meta data' payload: contract methods // to change the promise type suffixes or the delimiter just pass in a config objectconst configedWeb3Middleware =
Releases
Maintainers
Please reach out if you have any questions or comments!