@reactables/core 1.0.0-beta.3 → 1.0.0-beta.5

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/README.md CHANGED
@@ -27,8 +27,6 @@ Reactive state management with RxJS.
27
27
  1. [Action](#api-action)
28
28
  1. [Reducer](#api-reducer)
29
29
  1. [Testing Reactables](#testing)
30
- 1. [Flow Testing](#flow-testing)
31
- 1. [Marble Testing](#marble-testing)
32
30
 
33
31
  ## Installation <a name="installation"></a>
34
32
 
@@ -81,7 +79,7 @@ When initializing a [Reactable](#reactable-concept) we can declare effects. The
81
79
 
82
80
  ### Scoped Effects <a name="scoped-effects"></a>
83
81
 
84
- Scoped Effects are dynamically created streams scoped to a particular action & key combination when an action is dispatch.
82
+ Scoped Effects are dynamically created streams scoped to a particular action & key combination when an action is dispatched.
85
83
 
86
84
  <img src="https://raw.githubusercontent.com/reactables/reactables/main/documentation/SlideThreeScopedEffects.jpg" width="600" />
87
85
 
@@ -94,7 +92,7 @@ Actions and logic flow through the App in one direction and are **contained** in
94
92
 
95
93
  ### Basic Counter <a name="basic-counter-example"></a>
96
94
 
97
- Basic counter example. Button clicks dispatch actions to increment or reset the counter.
95
+ A basic counter example. Button clicks dispatch actions to increment or reset the counter.
98
96
 
99
97
  Design Diagram | Reactable | Try it out on StackBlitz.<br /> Choose your framework
100
98
  :-------------------------:|:-------------------------:|:-------------------------:
@@ -102,7 +100,7 @@ Design Diagram | Reactable | Try it out on StackBlitz.<br /
102
100
 
103
101
  ### Scoped Effects - Updating Todos <a name="scoped-effects-example"></a>
104
102
 
105
- Updating statuses of todo items shows scoped effects in action. An 'update todo' stream is created for each todo during update. Pending async calls in their respective stream are cancelled if a new request comes in with RxJS [switchMap](https://www.learnrxjs.io/learn-rxjs/operators/transformation/switchmap) operator.
103
+ Updating statuses of todo items shows scoped effects in action. An 'update todo' stream is created for each todo during update. Pending async calls in their respective stream are cancelled if a new request comes in with a RxJS [switchMap](https://www.learnrxjs.io/learn-rxjs/operators/transformation/switchmap) operator.
106
104
 
107
105
  Design Diagram | Reactable | Try it out on StackBlitz.<br /> Choose your framework
108
106
  :-------------------------:|:-------------------------:|:-------------------------:
@@ -110,7 +108,7 @@ Design Diagram | Reactable | Try it out on StackBlitz.<br /> Choo
110
108
 
111
109
  ### Connecting Multiple Reactables - Event Tickets <a name="connecting-hub-example"></a>
112
110
 
113
- This examples shows two set reactables. The first is responsible for updating state of the user controls. The second fetches prices based on input from the first set.
111
+ This examples shows two sets of reactables. The first is responsible for updating the state of user controls, while the second fetches prices based on input from the first.
114
112
 
115
113
  Design Diagram | Reactable | Try it out on StackBlitz.<br /> Choose your framework
116
114
  :-------------------------:|:-------------------------:|:-------------------------:
@@ -135,7 +133,7 @@ export interface ActionMap {
135
133
 
136
134
  ### RxBuilder <a name="rx-builder"></a>
137
135
 
138
- Factory function for building [Reactables](#reactable). Accepts a [RxConfig](#rx-confg) configuration object
136
+ Factory function for building [Reactables](#reactable). Accepts a [RxConfig](#rx-confg) configuration object.
139
137
 
140
138
  ```typescript
141
139
  type RxBuilder = <T, S extends Cases<T>>(config: RxConfig<T, S>) => Reactable<T, unknown>
@@ -221,7 +219,7 @@ interface Action<T = undefined> {
221
219
 
222
220
  #### Reducer <a name="api-reducer"></a>
223
221
 
224
- From [Redux Docs](https://redux.js.org/tutorials/fundamentals/part-3-state-actions-reducers)
222
+ From the [Redux Docs](https://redux.js.org/tutorials/fundamentals/part-3-state-actions-reducers):
225
223
  > Reducers are functions that take the current state and an action as arguments, and return a new state result
226
224
 
227
225
  ```typescript
@@ -229,11 +227,6 @@ type Reducer<T> = (state?: T, action?: Action<unknown>) => T;
229
227
  ```
230
228
 
231
229
  ## Testing Reactables<a name="testing"></a>
232
- ### Flow Testing<a name="flow-testing"></a>
233
-
234
- You can test a series of actions to simulate a defined user flow with the `testFlow` method from [`@reactables/testing`](https://github.com/reactables/reactables/blob/main/packages/testing/README.md) package. See [`@reactables/testing`](https://github.com/reactables/reactables/blob/main/packages/testing/README.md) for details.
235
-
236
- ### Marble Testing<a name="marble-testing"></a>
237
230
 
238
231
  We can use RxJS's built in [Marble Testing](https://rxjs.dev/guide/testing/marble-testing) for testing [Reactables](#reactable).
239
232
 
@@ -1,5 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
- export type Reactable<T, S = ActionMap> = [Observable<T>, S];
2
+ import { Action } from './Action';
3
+ export type Reactable<T, S = ActionMap> = [Observable<T>, S, Observable<Action<unknown>>?];
3
4
  export interface ActionMap {
4
5
  [key: string | number]: (payload?: unknown) => void | ActionMap;
5
6
  }
@@ -0,0 +1 @@
1
+ export { ofTypes } from './ofTypes';
@@ -0,0 +1,3 @@
1
+ import { OperatorFunction } from 'rxjs';
2
+ import { Action } from '../Models/Action';
3
+ export declare const ofTypes: (types: string[]) => OperatorFunction<Action<unknown>, Action<unknown>>;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './Models';
2
2
  export * from './Helpers';
3
+ export * from './Operators';
package/dist/index.js CHANGED
@@ -58,6 +58,13 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
58
58
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
59
59
  };
60
60
 
61
+ var ofTypes = function (types) { return function (dispatcher$) {
62
+ return dispatcher$.pipe(operators.filter(function (_a) {
63
+ var type = _a.type;
64
+ return types.includes(type);
65
+ }));
66
+ }; };
67
+
61
68
  var addEffects = function (actionCreator, scopedEffects) {
62
69
  return function (payload) { return (__assign(__assign({}, actionCreator(payload)), { scopedEffects: scopedEffects(payload) })); };
63
70
  };
@@ -280,7 +287,9 @@ var RxBuilder = function (_a) {
280
287
  return [
281
288
  hub.store({ reducer: reducer, debug: debug, storeValue: storeValue, name: sliceConfig.name }),
282
289
  actionsResult,
290
+ hub.messages$,
283
291
  ];
284
292
  };
285
293
 
286
294
  exports.RxBuilder = RxBuilder;
295
+ exports.ofTypes = ofTypes;
package/package.json CHANGED
@@ -16,5 +16,5 @@
16
16
  "peerDependencies": {
17
17
  "rxjs": "^6.0.0 || ^7.0.0"
18
18
  },
19
- "version": "1.0.0-beta.3"
19
+ "version": "1.0.0-beta.5"
20
20
  }
@@ -1,3 +0,0 @@
1
- import { OperatorFunction } from 'rxjs';
2
- import { Action } from '../Models/Action';
3
- export declare const ofType: (type: string) => OperatorFunction<Action<unknown>, Action<unknown>>;