@thi.ng/interceptors 3.2.78 → 3.2.80
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/CHANGELOG.md +1 -1
- package/event-bus.d.ts +28 -31
- package/event-bus.js +2 -2
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
package/event-bus.d.ts
CHANGED
|
@@ -2,32 +2,30 @@ import type { IDeref, IObjectOf, Maybe } from "@thi.ng/api";
|
|
|
2
2
|
import type { IAtom } from "@thi.ng/atom";
|
|
3
3
|
import { type EffectDef, type EffectPriority, type Event, type EventDef, type IDispatch, type Interceptor, type InterceptorContext, type InterceptorFn, type SideEffect } from "./api.js";
|
|
4
4
|
/**
|
|
5
|
-
* Batched event processor for using composable interceptors for event
|
|
6
|
-
*
|
|
5
|
+
* Batched event processor for using composable interceptors for event handling
|
|
6
|
+
* and side effects to execute the result of handled events.
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
|
-
* Events processed by this class are simple 2-element tuples/arrays of
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Events processed by this class are simple 2-element tuples/arrays of this
|
|
10
|
+
* form: `["event-id", payload?]`, where the `payload` is optional and can be of
|
|
11
|
+
* any type.
|
|
12
12
|
*
|
|
13
|
-
* Events are processed by registered handlers which transform each
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* and debugged.
|
|
13
|
+
* Events are processed by registered handlers which transform each event into a
|
|
14
|
+
* number of side effect descriptions to be executed later. This separation
|
|
15
|
+
* ensures event handlers themselves are pure functions and leads to more
|
|
16
|
+
* efficient reuse of side effecting operations. The pure data nature until the
|
|
17
|
+
* last stage of processing (the application side effects) too means that event
|
|
18
|
+
* flow can be much easier inspected and debugged.
|
|
20
19
|
*
|
|
21
|
-
* In this model a single event handler itself is an array of objects
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* (logging, validation, undo/redo triggers etc.).
|
|
20
|
+
* In this model a single event handler itself is an array of objects with `pre`
|
|
21
|
+
* and/or `post` keys and functions attached to each key. These functions are
|
|
22
|
+
* called interceptors, since each intercepts the processing of an event and can
|
|
23
|
+
* contribute their own side effects. Each event's interceptor chain is
|
|
24
|
+
* processed bi-directionally (`pre` in forward, `post` in reverse order) and
|
|
25
|
+
* the effects returned from each interceptor are merged/collected. The outcome
|
|
26
|
+
* of this setup is a more aspect-oriented, composable approach to event
|
|
27
|
+
* handling and allows to inject common, re-usable behaviors for multiple event
|
|
28
|
+
* types (logging, validation, undo/redo triggers etc.).
|
|
31
29
|
*
|
|
32
30
|
* Side effects are only processed after all event handlers have run.
|
|
33
31
|
* Furthermore, their order of execution can be configured with optional
|
|
@@ -40,18 +38,17 @@ import { type EffectDef, type EffectPriority, type Event, type EventDef, type ID
|
|
|
40
38
|
* - {@link StatelessEventBus.processEffects}
|
|
41
39
|
* - {@link StatelessEventBus.mergeEffects}
|
|
42
40
|
*
|
|
43
|
-
* The overall approach of this type of event processing is heavily
|
|
44
|
-
*
|
|
45
|
-
*
|
|
41
|
+
* The overall approach of this type of event processing is heavily based on the
|
|
42
|
+
* pattern initially pioneered by @Day8/re-frame, with the following
|
|
43
|
+
* differences:
|
|
46
44
|
*
|
|
47
|
-
* - stateless (see {@link EventBus} for the more common stateful
|
|
48
|
-
* alternative)
|
|
45
|
+
* - stateless (see {@link EventBus} for the more common stateful alternative)
|
|
49
46
|
* - standalone implementation (no assumptions about surrounding
|
|
50
47
|
* context/framework)
|
|
51
48
|
* - manual control over event queue processing
|
|
52
49
|
* - supports event cancellation (via FX_CANCEL side effect)
|
|
53
|
-
* - side effect collection (multiple side effects for same effect type
|
|
54
|
-
*
|
|
50
|
+
* - side effect collection (multiple side effects for same effect type per
|
|
51
|
+
* frame)
|
|
55
52
|
* - side effect priorities (to control execution order)
|
|
56
53
|
* - dynamic addition/removal of handlers & effects
|
|
57
54
|
*/
|
|
@@ -345,7 +342,7 @@ export declare class EventBus extends StatelessEventBus implements IDeref<any>,
|
|
|
345
342
|
* #### `EV_SET_VALUE`
|
|
346
343
|
*
|
|
347
344
|
* Resets state path to provided value. See
|
|
348
|
-
* [`setIn
|
|
345
|
+
* [`setIn`](https://docs.thi.ng/umbrella/paths/functions/setIn.html).
|
|
349
346
|
*
|
|
350
347
|
* Example event definition:
|
|
351
348
|
* ```js
|
|
@@ -358,7 +355,7 @@ export declare class EventBus extends StatelessEventBus implements IDeref<any>,
|
|
|
358
355
|
*
|
|
359
356
|
* Updates a state path's value with provided function and optional extra
|
|
360
357
|
* arguments. See
|
|
361
|
-
* [`updateIn
|
|
358
|
+
* [`updateIn`](https://docs.thi.ng/umbrella/paths/functions/updateIn.html).
|
|
362
359
|
*
|
|
363
360
|
* Example event definition:
|
|
364
361
|
* ```js
|
package/event-bus.js
CHANGED
|
@@ -517,7 +517,7 @@ class EventBus extends StatelessEventBus {
|
|
|
517
517
|
* #### `EV_SET_VALUE`
|
|
518
518
|
*
|
|
519
519
|
* Resets state path to provided value. See
|
|
520
|
-
* [`setIn
|
|
520
|
+
* [`setIn`](https://docs.thi.ng/umbrella/paths/functions/setIn.html).
|
|
521
521
|
*
|
|
522
522
|
* Example event definition:
|
|
523
523
|
* ```js
|
|
@@ -530,7 +530,7 @@ class EventBus extends StatelessEventBus {
|
|
|
530
530
|
*
|
|
531
531
|
* Updates a state path's value with provided function and optional extra
|
|
532
532
|
* arguments. See
|
|
533
|
-
* [`updateIn
|
|
533
|
+
* [`updateIn`](https://docs.thi.ng/umbrella/paths/functions/updateIn.html).
|
|
534
534
|
*
|
|
535
535
|
* Example event definition:
|
|
536
536
|
* ```js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/interceptors",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.80",
|
|
4
4
|
"description": "Interceptor based event bus, side effect & immutable state handling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@thi.ng/api": "^8.11.
|
|
46
|
-
"@thi.ng/atom": "^5.3.
|
|
47
|
-
"@thi.ng/checks": "^3.6.
|
|
48
|
-
"@thi.ng/errors": "^2.5.
|
|
49
|
-
"@thi.ng/logger": "^3.
|
|
50
|
-
"@thi.ng/paths": "^5.2.
|
|
45
|
+
"@thi.ng/api": "^8.11.20",
|
|
46
|
+
"@thi.ng/atom": "^5.3.21",
|
|
47
|
+
"@thi.ng/checks": "^3.6.23",
|
|
48
|
+
"@thi.ng/errors": "^2.5.26",
|
|
49
|
+
"@thi.ng/logger": "^3.1.1",
|
|
50
|
+
"@thi.ng/paths": "^5.2.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"esbuild": "^0.
|
|
54
|
-
"typedoc": "^0.27.
|
|
53
|
+
"esbuild": "^0.25.0",
|
|
54
|
+
"typedoc": "^0.27.7",
|
|
55
55
|
"typescript": "^5.7.3"
|
|
56
56
|
},
|
|
57
57
|
"keywords": [
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"status": "completed",
|
|
98
98
|
"year": 2016
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "9a0b33253fef092aaf301decf6ecd54317874d4c\n"
|
|
101
101
|
}
|