1.1.5 • Published 10 months ago
redux-effects-promise v1.1.5
redux-effects-promise
An implementation of declarative promises effects for redux. The solution is based on inversify library.
Installation
npm install redux-effects-promise --save
Dependencies
Usage
import 'reflect-metadata';
import { createStore } from 'redux';
import { Container } from 'inversify';
import { EffectsService, effectsMiddleware } from 'redux-effects-promise';
export const middlewares = [..., effectsMiddleware];
EffectsService.configure(new Container(), createStore(...));
import { EffectsService } from 'redux-effects-promise';
...
@provide(DashboardListEffects)
export class DashboardListEffects {
...
@EffectsService.effects('dashboard.list.load')
loadProducts(): Promise<IProduct[]> {
return this.api.loadProducts();
}
// Or ...
// @EffectsService.effects('dashboard.list.load')
// loadProducts(): IProduct[] {
// return [{ name: 'Product1', id: 1901 }, { name: 'Product2', id: 1902 }];
// }
}
import { AnyAction } from 'redux';
import { EffectsAction, EffectsService } from 'redux-effects-promise';
...
@provide(DashboardFormEffects)
export class DashboardFormEffects {
...
@EffectsService.effects('dashboard.form.submit')
saveProduct(action: AnyAction, state: IAppState): Promise<EffectsAction[]> {
return this.api.saveProduct(action.data)
.then(result => {
return [
EffectsAction.create('dashboard.form.submit.done', result),
EffectsAction.create('dashboard.list.update', action.data),
EffectsAction.create('dashboard.back', action.data) // Parameter1=action.data
];
});
}
@EffectsService.effects('dashboard.back')
back(): EffectsAction[] {
// A inheriting of the parameters works finely so input parameter
// "Parameter1" would pass within an action = { type: ..., data: ..., initialData: Parameter1 }
return [
EffectsAction.create('dashboard.list.deselect'),
EffectsAction.create('router.navigate', '/dashboard')
];
}
}
Preview
License
Licensed under MIT.
1.1.1
12 months ago
1.1.5
10 months ago
1.1.4
12 months ago
1.1.3
12 months ago
1.1.2
12 months ago
1.0.10
3 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago
0.0.22
7 years ago
0.0.21
7 years ago
0.0.20
7 years ago
0.0.19
7 years ago
0.0.18
8 years ago
0.0.17
8 years ago
0.0.16
8 years ago
0.0.15
8 years ago
0.0.14
8 years ago
0.0.13
8 years ago
0.0.12
8 years ago
0.0.11
8 years ago
0.0.10
8 years ago
0.0.9
8 years ago
0.0.8
8 years ago
0.0.7
8 years ago
0.0.6
8 years ago
0.0.5
8 years ago
0.0.4
8 years ago
0.0.3
8 years ago
0.0.2
8 years ago
0.0.1
8 years ago