Unresolved actions for redux
React redux library to deal with async actions
WARNING this is still in development
Major changes might be introduced in near future
Installation
npm i unresolved-actions-redux
Store setup
// Import unresolvedActionMiddleware;;; // Define dependencies and dependency resolverconst dependencies = { ; };// In this case dependency resolver is simple service object map, // but can be any function that takes service name and returns the serviceconst dependencyResolver = dependenciesserviceName; // add unresolved action middleware and pass dependency resolver const configureStore = { const middleware = ; return ;}; ;
Usage
This library works by catching async UnresolvedAction type actions and resolving them inside the middleware
Example of async action
/* login.js */ // Import Resolver; { // getState() and dispatch get injected // into the action and is accessible from this if !thisapplogin this; // dependencies are also accessible from this const name = await this; this; }// Decorate action with Resolver and pass required dependencies // as { alias in action: service name } object loginManager: 'api' login;
Example of calling async action
...; ...<Button onPress= { thisprops; } title="Login" />