@reactables/core 0.4.2-alpha.0 → 0.4.3-alpha.1

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.
@@ -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
- acc[key] = addEffects(acc[key], _case.effects);
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
- return __assign(__assign({}, action), { scopedEffects: _case.effects(action.payload) });
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
@@ -16,5 +16,5 @@
16
16
  "peerDependencies": {
17
17
  "rxjs": "^6.0.0 || ^7.0.0"
18
18
  },
19
- "version": "0.4.2-alpha.0"
19
+ "version": "0.4.3-alpha.1"
20
20
  }