@reactables/core 1.1.0 → 1.2.0-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.
- package/dist/Helpers/combine.d.ts +3 -0
- package/dist/Helpers/index.d.ts +1 -0
- package/dist/index.js +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Observable, ObservedValueOf } from 'rxjs';
|
|
2
|
+
import { Action, Reactable } from '../Models';
|
|
3
|
+
export declare const combine: <T extends Record<string, Reactable<unknown, unknown>>>(reactablesDict: T) => [Observable<{ [K_2 in keyof T]: Observable<T[K_2][0]>; } extends infer T_1 ? { [K in keyof T_1]: ObservedValueOf<{ [K_1 in keyof T]: Observable<T[K_1][0]>; }[K]>; } : never>, { [K_3 in keyof T]: T[K_3][1]; }, Observable<Action<unknown>>];
|
package/dist/Helpers/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -299,6 +299,25 @@ var storeValue = function (reactable) {
|
|
|
299
299
|
return [replaySubject$, __assign(__assign({}, actions), { destroy: destroy }), actions$];
|
|
300
300
|
};
|
|
301
301
|
|
|
302
|
+
var combine = function (reactablesDict) {
|
|
303
|
+
var _a = Object.entries(reactablesDict).reduce(function (acc, _a) {
|
|
304
|
+
var _b, _c;
|
|
305
|
+
var key = _a[0], _d = _a[1], state$ = _d[0], actions = _d[1], actions$ = _d[2];
|
|
306
|
+
return {
|
|
307
|
+
states: __assign(__assign({}, acc.states), (_b = {}, _b[key] = state$, _b)),
|
|
308
|
+
actions: __assign(__assign({}, acc.actions), (_c = {}, _c[key] = actions, _c)),
|
|
309
|
+
actions$: actions$ ? acc.actions$.concat(actions$) : acc.actions$
|
|
310
|
+
};
|
|
311
|
+
}, {
|
|
312
|
+
states: {},
|
|
313
|
+
actions: {},
|
|
314
|
+
actions$: []
|
|
315
|
+
}), states = _a.states, actions = _a.actions, actions$ = _a.actions$;
|
|
316
|
+
var states$ = rxjs.combineLatest(states);
|
|
317
|
+
return [states$, actions, rxjs.merge.apply(void 0, actions$)];
|
|
318
|
+
};
|
|
319
|
+
|
|
302
320
|
exports.RxBuilder = RxBuilder;
|
|
321
|
+
exports.combine = combine;
|
|
303
322
|
exports.ofTypes = ofTypes;
|
|
304
323
|
exports.storeValue = storeValue;
|
package/package.json
CHANGED