@reactables/core 0.4.3-alpha.0 → 0.4.4-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Helpers/createSlice.d.ts +2 -1
- package/dist/index.js +8 -2
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Effect } from '../Models/Effect';
|
|
1
2
|
import { Action, ActionCreator, ScopedEffects } from '../Models/Action';
|
|
2
3
|
import { Reducer } from '../Models/Hub';
|
|
3
4
|
export type SingleActionReducer<T, S> = (state: T, action: Action<S>) => T;
|
|
@@ -10,7 +11,7 @@ export interface Slice<T> {
|
|
|
10
11
|
export interface Cases<T> {
|
|
11
12
|
[key: string]: SingleActionReducer<T, unknown> | {
|
|
12
13
|
reducer: SingleActionReducer<T, unknown>;
|
|
13
|
-
effects?: (payload?: unknown) => ScopedEffects<unknown
|
|
14
|
+
effects?: ((payload?: unknown) => ScopedEffects<unknown>) | Effect<unknown, unknown>[];
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
export interface SliceConfig<T, S extends Cases<T>> {
|
package/dist/index.js
CHANGED
|
@@ -85,7 +85,10 @@ var createSlice = function (config) {
|
|
|
85
85
|
payload: payload
|
|
86
86
|
}); };
|
|
87
87
|
if (typeof _case !== 'function' && _case.effects) {
|
|
88
|
-
|
|
88
|
+
var effects = typeof _case.effects === 'function'
|
|
89
|
+
? _case.effects
|
|
90
|
+
: (function () { return ({ effects: _case.effects }); });
|
|
91
|
+
acc[key] = addEffects(acc[key], effects);
|
|
89
92
|
}
|
|
90
93
|
return acc;
|
|
91
94
|
}, {});
|
|
@@ -182,7 +185,10 @@ var RxBuilder = function (_a) {
|
|
|
182
185
|
return action$.pipe(operators.map(function (action) {
|
|
183
186
|
var _case = sliceConfig.reducers[action.type];
|
|
184
187
|
if (typeof _case !== 'function' && _case.effects) {
|
|
185
|
-
|
|
188
|
+
var effects_1 = typeof _case.effects === 'function'
|
|
189
|
+
? _case.effects
|
|
190
|
+
: (function () { return ({ effects: _case.effects }); });
|
|
191
|
+
return __assign(__assign({}, action), { scopedEffects: effects_1(action.payload) });
|
|
186
192
|
}
|
|
187
193
|
return action;
|
|
188
194
|
}));
|
package/package.json
CHANGED