nanoeffects 0.28.0 → 0.29.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/{action-creator-CcAEvUnw.d.ts → action-creator-jeEqIKgK.d.ts} +34 -32
- package/dist/actions.d.ts +18 -18
- package/dist/actions.js +1 -1
- package/dist/bus-0uYn_kRj.js +1 -0
- package/dist/context-DtUnzC-1.js +1 -0
- package/dist/context-types-Bme1mzkn.d.ts +31 -0
- package/dist/context.d.ts +8 -3
- package/dist/context.js +1 -1
- package/dist/{delay-18LJ8jSk.js → delay-5OhJZZQ0.js} +1 -1
- package/dist/dev.d.ts +2 -2
- package/dist/effects.d.ts +2 -2
- package/dist/effects.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/match.d.ts +3 -3
- package/dist/match.js +1 -1
- package/dist/{module-C_oEXw1n.d.ts → module-BWMW83qk.d.ts} +38 -38
- package/dist/notrace/{action-creator-DxOvVo8I.d.ts → action-creator-xpQ_I2h8.d.ts} +34 -32
- package/dist/notrace/actions.d.ts +52 -52
- package/dist/notrace/actions.js +1 -1
- package/dist/notrace/{bus-DmKn4SDD.js → bus-37nlVljc.js} +1 -1
- package/dist/notrace/effects.d.ts +2 -2
- package/dist/notrace/index.d.ts +2 -2
- package/dist/notrace/index.js +1 -1
- package/dist/notrace/{plugin-lJjjd-SN.d.ts → plugin-6LhNx0th.d.ts} +1 -1
- package/dist/notrace/policies.d.ts +1 -1
- package/dist/notrace/redux.d.ts +1 -1
- package/dist/observable.d.ts +43 -1
- package/dist/observable.js +1 -1
- package/dist/onAbort-BgMfspK4.js +1 -0
- package/dist/oop.d.ts +3 -3
- package/dist/oop.js +1 -1
- package/dist/{plugin-CuvIgjnX.d.ts → plugin-BaErevLy.d.ts} +2 -2
- package/dist/policies.d.ts +2 -2
- package/dist/policies.js +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/redux.d.ts +1 -1
- package/dist/scope.d.ts +9 -9
- package/dist/signal-field-key-CWT-3OXC.js +1 -0
- package/dist/signal.d.ts +34 -6
- package/dist/signal.js +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/trace.d.ts +20 -5
- package/dist/trace.js +1 -1
- package/dist/{types-FV8fuvI9.d.ts → types-D5xsR37j.d.ts} +2 -2
- package/dist/vue.d.ts +1 -1
- package/dist/{with-policy-3bhFLEXs.d.ts → with-policy-BZVRBUOm.d.ts} +1 -1
- package/dist/{with-policy-D-SQRkPh.js → with-policy-C6BIiPIi.js} +1 -1
- package/docs/README.md +13 -1
- package/docs/actions.md +27 -1
- package/docs/chat-example.md +12 -0
- package/docs/chat-widget.md +7 -7
- package/docs/context.md +33 -1
- package/docs/effects.md +20 -9
- package/docs/guide.md +20 -2
- package/docs/migrating-from-effector.md +11 -0
- package/docs/observable.md +43 -0
- package/docs/oop.md +17 -0
- package/docs/package.md +22 -13
- package/docs/plugins.md +69 -11
- package/docs/query-libraries.md +273 -5
- package/docs/react.md +12 -2
- package/docs/scope.md +14 -2
- package/docs/semantics.md +10 -0
- package/docs/server.md +3 -3
- package/docs/stability.md +2 -2
- package/docs/tracing.md +74 -6
- package/docs/typescript.md +1 -1
- package/llms-full.txt +671 -66
- package/llms.txt +7 -7
- package/package.json +4 -4
- package/skills/nanoeffects/SKILL.md +2 -2
- package/dist/bus-DlpEluzd.js +0 -1
- package/dist/context-UcmrAIhP.js +0 -1
- package/dist/context-types-hCKgU8sC.d.ts +0 -14
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as ScopeSlots, r as Scoped } from "./types-
|
|
3
|
-
//#region src/actions/
|
|
4
|
-
/** What `
|
|
5
|
-
type
|
|
1
|
+
import { A as HandledCall, G as PayloadOf, H as EventMap, Z as UnsubscribeCallback, b as Context, c as Scope, g as Actions, k as Handled, q as Task, u as WithScope, v as Bus, z as handledCall } from "./action-creator-jeEqIKgK.js";
|
|
2
|
+
import { n as ScopeSlots, r as Scoped } from "./types-D5xsR37j.js";
|
|
3
|
+
//#region src/actions/handled.d.ts
|
|
4
|
+
/** What `createAction` returns: an action that also tells whether an action is of its type. */
|
|
5
|
+
type MadeHandled<P, R, T extends string> = Handled<P, R> & {
|
|
6
6
|
readonly type: T;
|
|
7
|
-
/** Tells whether an action has the type of this
|
|
7
|
+
/** Tells whether an action has the type of this action, and narrows its type. */
|
|
8
8
|
match(action: {
|
|
9
9
|
type: string;
|
|
10
10
|
payload?: unknown;
|
|
@@ -14,14 +14,14 @@ type MadeCommand<P, R, T extends string> = Command<P, R> & {
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
/** `Made`, called so that its calls carry the scope fields `F`; `Made` itself when there are none. */
|
|
17
|
-
type CarryingCalls<Made, P, R, F> = [unknown] extends [F] ? Made : ((payload: P) =>
|
|
18
|
-
/**
|
|
19
|
-
type
|
|
20
|
-
/**
|
|
21
|
-
type Binding<E extends EventMap = EventMap> = readonly [
|
|
17
|
+
type CarryingCalls<Made, P, R, F> = [unknown] extends [F] ? Made : ((payload: P) => HandledCall<P, R> & WithScope<F>) & Made & WithScope<F>;
|
|
18
|
+
/** An action made with a scope: its calls carry the fields of that scope, for the checker. */
|
|
19
|
+
type ScopedHandled<P, R, T extends string, F> = ((payload: P) => HandledCall<P, R> & WithScope<F>) & MadeHandled<P, R, T> & WithScope<F>;
|
|
20
|
+
/** An action (or its type) with the handler to bind to it; `setHandler` makes one. */
|
|
21
|
+
type Binding<E extends EventMap = EventMap> = readonly [Handled<never, unknown> | string, Task<never, E, unknown>];
|
|
22
22
|
/**
|
|
23
23
|
* Pairs an action with the handler to bind to it, for `actionsPlugin`. For a
|
|
24
|
-
*
|
|
24
|
+
* action (an action made with a handler, or with a `Call` type) it checks that
|
|
25
25
|
* the handler fits; any other action is accepted with a handler of any payload.
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
@@ -29,21 +29,21 @@ type Binding<E extends EventMap = EventMap> = readonly [Command<never, unknown>
|
|
|
29
29
|
* bus.use(actionsPlugin([setHandler(sendMail, smtpSend)]));
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
declare function setHandler<P, R, E extends EventMap>(
|
|
32
|
+
declare function setHandler<P, R, E extends EventMap>(handled: Handled<P, R>, fn: Task<P, E, R>): Binding<E>;
|
|
33
33
|
declare function setHandler<A extends {
|
|
34
34
|
readonly type: string;
|
|
35
35
|
}, E extends EventMap>(action: A, fn: LooseHandler<A, E>): Binding<E>;
|
|
36
36
|
/**
|
|
37
|
-
* The handler an action that is not
|
|
38
|
-
* (a creator whose calls are
|
|
37
|
+
* The handler an action that is not an action can have: any. An action
|
|
38
|
+
* (a creator whose calls are calls of an action with a handler) is not accepted here, so its own
|
|
39
39
|
* overload checks the handler against its payload and result.
|
|
40
40
|
*/
|
|
41
41
|
type LooseHandler<A, E extends EventMap> = A extends ((...args: never[]) => {
|
|
42
|
-
readonly [
|
|
42
|
+
readonly [handledCall]: unknown;
|
|
43
43
|
}) ? never : Task<never, E, unknown>;
|
|
44
44
|
/** The registry of handlers that `actionsPlugin` returns: `run` for the bus, `handle` to bind more. */
|
|
45
45
|
interface Registry$1<E extends EventMap> extends Actions {
|
|
46
|
-
handle<P, R>(
|
|
46
|
+
handle<P, R>(handled: Handled<P, R>, fn: Task<P, E, R>): UnsubscribeCallback;
|
|
47
47
|
/** Also an action made without a handler: what is emitted for its type runs `fn` and returns its result. */
|
|
48
48
|
handle<A extends {
|
|
49
49
|
readonly type: string;
|
|
@@ -52,25 +52,25 @@ interface Registry$1<E extends EventMap> extends Actions {
|
|
|
52
52
|
handle(bindings: readonly Binding<E>[]): UnsubscribeCallback;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* The plugin that gives a bus the handlers bound to
|
|
55
|
+
* The plugin that gives a bus the handlers bound to actions:
|
|
56
56
|
* `bus.use(actionsPlugin(bindings))` makes the registry, sets it as the
|
|
57
|
-
*
|
|
57
|
+
* actions of the bus and returns it. Each bus has its own, so each test can
|
|
58
58
|
* have its own implementation. `handle` binds more later and returns the
|
|
59
59
|
* function that unbinds. A second `actionsPlugin` on the same bus binds its
|
|
60
60
|
* list in the registry that is there and returns it, so the order of the
|
|
61
|
-
* plugins does not matter. A `
|
|
61
|
+
* plugins does not matter. A `actions` that is not such a registry (a custom
|
|
62
62
|
* runner) is replaced.
|
|
63
63
|
*
|
|
64
|
-
* What the bus runs for
|
|
65
|
-
*
|
|
64
|
+
* What the bus runs for an action: the handler bound last, else the one the
|
|
65
|
+
* action was created with, else it throws `No handler for action "..."`.
|
|
66
66
|
*
|
|
67
67
|
* @example
|
|
68
68
|
* ```ts
|
|
69
69
|
* const bus = createBus<Events>();
|
|
70
|
-
* const
|
|
70
|
+
* const actions = bus.use(actionsPlugin([setHandler(sendMail, smtpSend)]));
|
|
71
71
|
*
|
|
72
|
-
* const unbind =
|
|
73
|
-
* unbind(); // the
|
|
72
|
+
* const unbind = actions.handle(getUser, async () => fakeUser);
|
|
73
|
+
* unbind(); // the action's own handler is back
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
76
76
|
declare const actionsPlugin: <E extends EventMap>(bindings?: readonly Binding<E>[]) => (bus: Bus<E>) => Registry$1<E>;
|
|
@@ -78,23 +78,23 @@ declare const actionsPlugin: <E extends EventMap>(bindings?: readonly Binding<E>
|
|
|
78
78
|
//#region src/actions/module.d.ts
|
|
79
79
|
/**
|
|
80
80
|
* What a module's `setup` gets: the context of the module's task, so `on`,
|
|
81
|
-
* `emit` and `run` work as in a handler, plus `handle` to bind
|
|
81
|
+
* `emit` and `run` work as in a handler, plus `handle` to bind actions, `use`
|
|
82
82
|
* to mount sub-modules and `spawn` to start a background task. Everything the
|
|
83
83
|
* module does is undone when it is unmounted.
|
|
84
84
|
*/
|
|
85
85
|
type ModuleContext<E extends EventMap = EventMap> = Context<E> & {
|
|
86
|
-
/** Binds the handler of
|
|
87
|
-
handle<P, R>(
|
|
88
|
-
/** Also an action made without a handler: the handler answers it as it would a
|
|
86
|
+
/** Binds the handler of an action, or a list of them; undone on unmount. */
|
|
87
|
+
handle<P, R>(handled: Handled<P, R>, fn: Task<P, E, R>): UnsubscribeCallback;
|
|
88
|
+
/** Also an action made without a handler: the handler answers it as it would one made with a handler. */
|
|
89
89
|
handle<A extends {
|
|
90
90
|
readonly type: string;
|
|
91
91
|
}>(action: A, fn: LooseHandler<A, E>): UnsubscribeCallback;
|
|
92
92
|
handle(type: string, fn: Task<never, E, unknown>): UnsubscribeCallback;
|
|
93
93
|
handle(bindings: readonly Binding<E>[]): UnsubscribeCallback;
|
|
94
94
|
/**
|
|
95
|
-
* Brings sub-modules and
|
|
96
|
-
* unmounted with this one.
|
|
97
|
-
* as long as this module is mounted;
|
|
95
|
+
* Brings sub-modules and actions, in any order. A sub-module is mounted and
|
|
96
|
+
* unmounted with this one. An action is bound to the handler it carries, for
|
|
97
|
+
* as long as this module is mounted; an action that answers by itself keeps
|
|
98
98
|
* answering after the module is gone, since the handler is its own. The
|
|
99
99
|
* returned function undoes just this call, e.g. for what was added later from
|
|
100
100
|
* a listener.
|
|
@@ -116,7 +116,7 @@ type Module<E extends EventMap = EventMap> = {
|
|
|
116
116
|
readonly scope?: Scope;
|
|
117
117
|
};
|
|
118
118
|
/**
|
|
119
|
-
* Describes one domain of an app: the
|
|
119
|
+
* Describes one domain of an app: the actions it handles, the events it
|
|
120
120
|
* listens to, its sub-modules and its background tasks. The `name` shows up as
|
|
121
121
|
* the type of the module's tasks in the trace.
|
|
122
122
|
*
|
|
@@ -158,7 +158,7 @@ interface WithApp {
|
|
|
158
158
|
}
|
|
159
159
|
/** What `modulePlugin` returns. */
|
|
160
160
|
type ModuleApi<E extends EventMap = EventMap> = {
|
|
161
|
-
/** The registry of
|
|
161
|
+
/** The registry of action handlers of the bus: the one it was made with, or the app's own. */
|
|
162
162
|
actions: Registry<E>;
|
|
163
163
|
/**
|
|
164
164
|
* Mounts modules, in the order given, and returns the function that unmounts them, last
|
|
@@ -187,17 +187,17 @@ type ModuleApi<E extends EventMap = EventMap> = {
|
|
|
187
187
|
* of one of its methods. By then every plugin is on the bus, so the plugins can
|
|
188
188
|
* be used in any order. The `on`, `once` and `off` calls made in between are
|
|
189
189
|
* held and made right after the modules, so the listeners of a module stay
|
|
190
|
-
* ahead of them. The bus runs the
|
|
190
|
+
* ahead of them. The bus runs the actions that the modules bind: the registry
|
|
191
191
|
* that the bus has is used (a later `actionsPlugin` binds in it), otherwise the
|
|
192
192
|
* app attaches its own, as `app.actions`. The app is also `bus.app`.
|
|
193
193
|
*
|
|
194
194
|
* A module is known by its `name`: mounting a module whose name is taken
|
|
195
195
|
* replaces the mounted one, which is unmounted first. That is what hot reload
|
|
196
196
|
* needs (see `docs/hmr.md`): the new version of a module file mounts again and
|
|
197
|
-
* the old version goes away with its subscriptions,
|
|
197
|
+
* the old version goes away with its subscriptions, actions and tasks.
|
|
198
198
|
*
|
|
199
199
|
* Unmounting undoes everything the module did: its subscriptions, its bound
|
|
200
|
-
*
|
|
200
|
+
* actions, its sub-modules and its background tasks. `dispose` unmounts them
|
|
201
201
|
* all, and a disposed app cannot mount modules.
|
|
202
202
|
*
|
|
203
203
|
* @example
|
|
@@ -220,4 +220,4 @@ type ModuleApi<E extends EventMap = EventMap> = {
|
|
|
220
220
|
*/
|
|
221
221
|
declare const modulePlugin: <E extends EventMap>(modules?: readonly Module<E>[]) => (bus: Bus<E> & ScopeSlots & WithApp) => ModuleApi<E>;
|
|
222
222
|
//#endregion
|
|
223
|
-
export { createModule as a, CarryingCalls as c, actionsPlugin as d, setHandler as f, WithApp as i,
|
|
223
|
+
export { createModule as a, CarryingCalls as c, actionsPlugin as d, setHandler as f, WithApp as i, MadeHandled as l, ModuleApi as n, modulePlugin as o, ModuleContext as r, Binding as s, Module as t, ScopedHandled as u };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
//#region src/core/types.d.ts
|
|
2
|
-
/** The third argument of `on` and `once`: read by
|
|
2
|
+
/** The third argument of `on` and `once`: each field is read by the plugin that names it, ignored without it. */
|
|
3
3
|
type ListenerOptions = {
|
|
4
|
-
/** Names the listener in the trace: each call of it is a task with this `type`. */
|
|
4
|
+
/** Names the listener in the trace: each call of it is a task with this `type`. Read by `tracePlugin`. */
|
|
5
5
|
traceId?: string;
|
|
6
|
+
/** Removes the listener when this aborts, and adds none if it aborted already. Read by `signalPlugin`. */
|
|
7
|
+
signal?: AbortSignal;
|
|
6
8
|
};
|
|
7
9
|
type PayloadOf<P> = undefined extends P ? [payload?: P] : [payload: P];
|
|
8
10
|
type EventMap = Record<string, unknown>;
|
|
9
11
|
type Keys<E> = keyof E & string;
|
|
10
12
|
type Task<P, E extends EventMap, R = unknown> = (payload: P, ctx: Context<E>) => R;
|
|
11
|
-
type EffectName = "every" | "latest" | "leading" | "debounce" | "throttle" | "run" | "all" | "race" | "retry" | "timeout" | "poll" | "take" | "queue" | "allSettled" | "
|
|
13
|
+
type EffectName = "every" | "latest" | "leading" | "debounce" | "throttle" | "run" | "all" | "race" | "retry" | "timeout" | "poll" | "take" | "queue" | "allSettled" | "action" | "emit";
|
|
12
14
|
type Phase = "start" | "done" | "error" | "cancel" | "drop";
|
|
13
15
|
type UnsubscribeCallback = () => void;
|
|
14
16
|
//#endregion
|
|
@@ -98,27 +100,27 @@ type Action<E extends EventMap> = {
|
|
|
98
100
|
};
|
|
99
101
|
type EventLike<E extends EventMap> = { [K in EventKey<E>]: WithPayload<E, K>; }[Keys<E>];
|
|
100
102
|
/**
|
|
101
|
-
* Brands `{ type, payload }` from a
|
|
103
|
+
* Brands `{ type, payload }` from a call of an action with a handler so `emit` can run the action.
|
|
102
104
|
* Not enumerable on the object.
|
|
103
105
|
*/
|
|
104
|
-
declare const
|
|
106
|
+
declare const handledCall: unique symbol;
|
|
105
107
|
/**
|
|
106
|
-
* What `
|
|
107
|
-
* that
|
|
108
|
+
* What `action(payload)` returns: an action-shaped value that `emit` runs as
|
|
109
|
+
* that action. A plain `{ type, payload }` without this brand is notify-only.
|
|
108
110
|
*/
|
|
109
|
-
type
|
|
111
|
+
type HandledCall<P = unknown, R = unknown> = {
|
|
110
112
|
type: string;
|
|
111
113
|
payload: P;
|
|
112
|
-
readonly [
|
|
114
|
+
readonly [handledCall]: Handled<P, R>;
|
|
113
115
|
};
|
|
114
116
|
/**
|
|
115
117
|
* A typed request for a result. Calling it builds `{ type, payload }` like
|
|
116
|
-
* `createAction`; `bus.emit(
|
|
118
|
+
* `createAction`; `bus.emit(action(payload))` (or `bus.emit(action, payload)`)
|
|
117
119
|
* runs the handler as a task and returns what it returns. Made by
|
|
118
|
-
* `
|
|
120
|
+
* `createAction` in `nanoeffects/actions`.
|
|
119
121
|
*/
|
|
120
|
-
type
|
|
121
|
-
(payload: P):
|
|
122
|
+
type Handled<P = never, R = unknown> = {
|
|
123
|
+
(payload: P): HandledCall<P, R>;
|
|
122
124
|
readonly type: string;
|
|
123
125
|
/** Wraps the handler that really runs, e.g. to route its outcome. */
|
|
124
126
|
readonly wrap?: (run: (payload: never, ctx: never) => unknown) => (payload: never, ctx: never) => unknown;
|
|
@@ -128,15 +130,15 @@ type Command<P = never, R = unknown> = {
|
|
|
128
130
|
* `actionsPlugin` in `nanoeffects/actions`, holds the handlers bound to
|
|
129
131
|
* actions and runs the right one, so a bus without `actions` carries none of
|
|
130
132
|
* that. `bound` tells, for an event type, whether a handler is bound to it: an
|
|
131
|
-
* action with no handler of its own is
|
|
132
|
-
* no `bound` runs
|
|
133
|
+
* action with no handler of its own is an action only then. A runner that has
|
|
134
|
+
* no `bound` runs actions only.
|
|
133
135
|
*/
|
|
134
136
|
interface Actions {
|
|
135
|
-
run(
|
|
136
|
-
bound?(type: string):
|
|
137
|
+
run(handled: Handled, payload: unknown, ctx: unknown): unknown;
|
|
138
|
+
bound?(type: string): Handled | undefined;
|
|
137
139
|
}
|
|
138
|
-
/** Anything `emit` takes as its first argument: an event type, an action or a
|
|
139
|
-
type Emittable<E extends EventMap> = EventKey<E> |
|
|
140
|
+
/** Anything `emit` takes as its first argument: an event type, an action creator or a call of one. */
|
|
141
|
+
type Emittable<E extends EventMap> = EventKey<E> | Handled | HandledCall | EventLike<E>;
|
|
140
142
|
type Emit<E extends EventMap> = {
|
|
141
143
|
/**
|
|
142
144
|
* On a bus without an event map the caller can say what a handler bound for
|
|
@@ -145,11 +147,11 @@ type Emit<E extends EventMap> = {
|
|
|
145
147
|
*/
|
|
146
148
|
<R = void>(type: string extends EventKey<E> ? string : never, ...payload: unknown[]): R;
|
|
147
149
|
<K extends EventKey<E>>(event: K, ...payload: PayloadOf<DataOf<E[K]>>): ResultOf<E[K]>;
|
|
148
|
-
/** Before Handler:
|
|
149
|
-
<P, R>(
|
|
150
|
+
/** Before Handler: an action is callable too, and must return its result type. */
|
|
151
|
+
<P, R>(handled: Handled<P, R>, ...payload: PayloadOf<P>): R;
|
|
150
152
|
/** A scope as the second argument replaces context fields for the tasks of this emit; see `scopePlugin`. */
|
|
151
|
-
<P, R, F>(call:
|
|
152
|
-
<P, R>(call:
|
|
153
|
+
<P, R, F>(call: HandledCall<P, R> & WithScope<F>, scope?: EmitScope<E, F>): R;
|
|
154
|
+
<P, R>(call: HandledCall<P, R>, scope?: EmitScope<E>): R;
|
|
153
155
|
<K extends EventKey<E>, R>(event: Handler<E, R, K>, ...payload: PayloadOf<DataOf<E[K]>>): R;
|
|
154
156
|
<F>(event: EventLike<E> & WithScope<F>, scope?: EmitScope<E, F>): void;
|
|
155
157
|
(event: EventLike<E>, scope?: EmitScope<E>): void;
|
|
@@ -158,15 +160,15 @@ type On<E extends EventMap> = {
|
|
|
158
160
|
(event: AnyEvent, fn: Task<EventPayload<E>, E>, options?: ListenerOptions): UnsubscribeCallback;
|
|
159
161
|
<K extends EventKey<E>>(event: K, fn: Task<DataOf<E[K]>, E>, options?: ListenerOptions): UnsubscribeCallback;
|
|
160
162
|
/** An action creator without a payload type: the payload comes from the event map. */
|
|
161
|
-
/** The creators and
|
|
163
|
+
/** The creators and actions that carry a scope come first: the handler sees their fields. */
|
|
162
164
|
<K extends EventKey<E>, F>(creator: FreeActionCreator<K, F> & WithScope<F>, fn: Task<DataOf<E[K]>, WithFields<E, F>>, options?: ListenerOptions): UnsubscribeCallback;
|
|
163
165
|
<P, F>(creator: ActionCreator<P, string, PayloadOf<P>, F> & WithScope<F>, fn: Task<P, WithFields<E, F>>, options?: ListenerOptions): UnsubscribeCallback;
|
|
164
|
-
<P, F>(
|
|
166
|
+
<P, F>(handled: Handled<P, unknown> & WithScope<F>, fn: Task<P, WithFields<E, F>>, options?: ListenerOptions): UnsubscribeCallback;
|
|
165
167
|
<K extends EventKey<E>>(creator: FreeActionCreator<K>, fn: Task<DataOf<E[K]>, E>, options?: ListenerOptions): UnsubscribeCallback;
|
|
166
168
|
/** An action creator: the payload comes from it, so an event map is not needed. */
|
|
167
169
|
<P>(creator: ActionCreator<P>, fn: Task<P, E>, options?: ListenerOptions): UnsubscribeCallback;
|
|
168
|
-
/**
|
|
169
|
-
<P>(
|
|
170
|
+
/** An action: the payload comes from it too. */
|
|
171
|
+
<P>(handled: Handled<P, unknown>, fn: Task<P, E>, options?: ListenerOptions): UnsubscribeCallback;
|
|
170
172
|
<K extends EventKey<E>, Event extends {
|
|
171
173
|
type: K;
|
|
172
174
|
}>(event: Event & {
|
|
@@ -185,7 +187,7 @@ type Off<E extends EventMap> = {
|
|
|
185
187
|
}>(event: Event & {
|
|
186
188
|
type: K;
|
|
187
189
|
}, fn: Task<DataOf<E[K]>, E>): void;
|
|
188
|
-
<P>(
|
|
190
|
+
<P>(handled: Handled<P, unknown>, fn?: Task<P, E>): void;
|
|
189
191
|
};
|
|
190
192
|
declare const contextKey: unique symbol;
|
|
191
193
|
/**
|
|
@@ -275,7 +277,7 @@ interface Bus<E extends EventMap> {
|
|
|
275
277
|
use<R>(plugin: (bus: Bus<E>) => R): R;
|
|
276
278
|
/** `BusOptions.context` and `.trace`, and `actions`, for what makes tasks of its own, like `modulePlugin`. */
|
|
277
279
|
readonly ctx?: ContextOption<E> | undefined;
|
|
278
|
-
/** What runs the handlers of actions; `actionsPlugin` and `modulePlugin` set it. Without one
|
|
280
|
+
/** What runs the handlers of actions; `actionsPlugin` and `modulePlugin` set it. Without one an action runs its own handler. */
|
|
279
281
|
actions?: Actions | undefined;
|
|
280
282
|
readonly trace?: Tracer | undefined;
|
|
281
283
|
/** Called with every new task context to add fields to it, for what needs the task, like `effectsPlugin`. Chain to the previous one. */
|
|
@@ -294,7 +296,7 @@ type BusOptions<E extends EventMap> = {
|
|
|
294
296
|
onError?: (error: unknown, event: Action<E>) => void;
|
|
295
297
|
/**
|
|
296
298
|
* Called when an event is emitted and nobody listens to it: the usual sign
|
|
297
|
-
* of a typo in an event name. Not called for
|
|
299
|
+
* of a typo in an event name. Not called for actions, nor for an action with
|
|
298
300
|
* a handler bound in `actions`, which always have a handler to run. Typically a warning in development only.
|
|
299
301
|
*
|
|
300
302
|
* @example
|
|
@@ -345,7 +347,7 @@ type BoundForm<F> = typeof bound extends keyof F ? NonNullable<F[typeof bound &
|
|
|
345
347
|
//#endregion
|
|
346
348
|
//#region src/core/scope-types.d.ts
|
|
347
349
|
declare const scopeFields: unique symbol;
|
|
348
|
-
/** What an action creator
|
|
350
|
+
/** What an action creator or a call knows of the scope it was made with: its fields, for the checker. */
|
|
349
351
|
type WithScope<F> = {
|
|
350
352
|
readonly [scopeFields]: F;
|
|
351
353
|
};
|
|
@@ -454,4 +456,4 @@ interface ActionCreator<P = void, T extends string = string, A extends unknown[]
|
|
|
454
456
|
toString(): T;
|
|
455
457
|
}
|
|
456
458
|
//#endregion
|
|
457
|
-
export { Off as A, Task as B,
|
|
459
|
+
export { Off as A, Task as B, EventLike as C, HandledCall as D, Handled as E, createBus as F, handledCall as I, EventMap as L, WithContext as M, WithSignal as N, Handler as O, WithType as P, Keys as R, EventKey as S, EventsOf as T, UnsubscribeCallback as V, Context as _, WithPayload as a, Emit as b, WithScope as c, Effects as d, Action as f, BusOptions as g, Bus as h, FreeActionCreator as i, On as j, HandlerRef as k, BoundForm as l, AnyEvent as m, Call as n, Scope as o, Actions as p, Free as r, WithFields as s, ActionCreator as t, Effect as u, ContextOf as v, EventPayload as w, Emittable as x, ContextOption as y, PayloadOf as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as Task,
|
|
2
|
-
import { t as BoundOf } from "./plugin-
|
|
1
|
+
import { B as Task, D as HandledCall, E as Handled, I as handledCall, L as EventMap, S as EventKey, V as UnsubscribeCallback, _ as Context, c as WithScope, d as Effects, h as Bus, i as FreeActionCreator, n as Call, o as Scope, p as Actions, r as Free, s as WithFields, t as ActionCreator, z as PayloadOf } from "./action-creator-xpQ_I2h8.js";
|
|
2
|
+
import { t as BoundOf } from "./plugin-6LhNx0th.js";
|
|
3
3
|
import { t as OriginOptions } from "./origin-key-CxK0SkeG.js";
|
|
4
4
|
//#region src/scope/types.d.ts
|
|
5
5
|
/**
|
|
@@ -23,11 +23,11 @@ type FieldsOfScope<E extends EventMap, S extends Scope> = [keyof S] extends [nev
|
|
|
23
23
|
*/
|
|
24
24
|
type Scoped<E extends EventMap, S extends Scope> = WithFields<E, FieldsOfScope<E, S>>;
|
|
25
25
|
//#endregion
|
|
26
|
-
//#region src/actions/
|
|
27
|
-
/** What `
|
|
28
|
-
type
|
|
26
|
+
//#region src/actions/handled.d.ts
|
|
27
|
+
/** What `createAction` returns: an action that also tells whether an action is of its type. */
|
|
28
|
+
type MadeHandled<P, R, T extends string> = Handled<P, R> & {
|
|
29
29
|
readonly type: T;
|
|
30
|
-
/** Tells whether an action has the type of this
|
|
30
|
+
/** Tells whether an action has the type of this action, and narrows its type. */
|
|
31
31
|
match(action: {
|
|
32
32
|
type: string;
|
|
33
33
|
payload?: unknown;
|
|
@@ -37,14 +37,14 @@ type MadeCommand<P, R, T extends string> = Command<P, R> & {
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
/** `Made`, called so that its calls carry the scope fields `F`; `Made` itself when there are none. */
|
|
40
|
-
type CarryingCalls<Made, P, R, F> = [unknown] extends [F] ? Made : ((payload: P) =>
|
|
41
|
-
/**
|
|
42
|
-
type
|
|
43
|
-
/**
|
|
44
|
-
type Binding<E extends EventMap = EventMap> = readonly [
|
|
40
|
+
type CarryingCalls<Made, P, R, F> = [unknown] extends [F] ? Made : ((payload: P) => HandledCall<P, R> & WithScope<F>) & Made & WithScope<F>;
|
|
41
|
+
/** An action made with a scope: its calls carry the fields of that scope, for the checker. */
|
|
42
|
+
type ScopedHandled<P, R, T extends string, F> = ((payload: P) => HandledCall<P, R> & WithScope<F>) & MadeHandled<P, R, T> & WithScope<F>;
|
|
43
|
+
/** An action (or its type) with the handler to bind to it; `setHandler` makes one. */
|
|
44
|
+
type Binding<E extends EventMap = EventMap> = readonly [Handled<never, unknown> | string, Task<never, E, unknown>];
|
|
45
45
|
/**
|
|
46
46
|
* Pairs an action with the handler to bind to it, for `actionsPlugin`. For a
|
|
47
|
-
*
|
|
47
|
+
* action (an action made with a handler, or with a `Call` type) it checks that
|
|
48
48
|
* the handler fits; any other action is accepted with a handler of any payload.
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
@@ -52,21 +52,21 @@ type Binding<E extends EventMap = EventMap> = readonly [Command<never, unknown>
|
|
|
52
52
|
* bus.use(actionsPlugin([setHandler(sendMail, smtpSend)]));
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
|
-
export declare function setHandler<P, R, E extends EventMap>(
|
|
55
|
+
export declare function setHandler<P, R, E extends EventMap>(handled: Handled<P, R>, fn: Task<P, E, R>): Binding<E>;
|
|
56
56
|
export declare function setHandler<A extends {
|
|
57
57
|
readonly type: string;
|
|
58
58
|
}, E extends EventMap>(action: A, fn: LooseHandler<A, E>): Binding<E>;
|
|
59
59
|
/**
|
|
60
|
-
* The handler an action that is not
|
|
61
|
-
* (a creator whose calls are
|
|
60
|
+
* The handler an action that is not an action can have: any. An action
|
|
61
|
+
* (a creator whose calls are calls of an action with a handler) is not accepted here, so its own
|
|
62
62
|
* overload checks the handler against its payload and result.
|
|
63
63
|
*/
|
|
64
64
|
type LooseHandler<A, E extends EventMap> = A extends ((...args: never[]) => {
|
|
65
|
-
readonly [
|
|
65
|
+
readonly [handledCall]: unknown;
|
|
66
66
|
}) ? never : Task<never, E, unknown>;
|
|
67
67
|
/** The registry of handlers that `actionsPlugin` returns: `run` for the bus, `handle` to bind more. */
|
|
68
68
|
interface Registry$1<E extends EventMap> extends Actions {
|
|
69
|
-
handle<P, R>(
|
|
69
|
+
handle<P, R>(handled: Handled<P, R>, fn: Task<P, E, R>): UnsubscribeCallback;
|
|
70
70
|
/** Also an action made without a handler: what is emitted for its type runs `fn` and returns its result. */
|
|
71
71
|
handle<A extends {
|
|
72
72
|
readonly type: string;
|
|
@@ -75,38 +75,38 @@ interface Registry$1<E extends EventMap> extends Actions {
|
|
|
75
75
|
handle(bindings: readonly Binding<E>[]): UnsubscribeCallback;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* The plugin that gives a bus the handlers bound to
|
|
78
|
+
* The plugin that gives a bus the handlers bound to actions:
|
|
79
79
|
* `bus.use(actionsPlugin(bindings))` makes the registry, sets it as the
|
|
80
|
-
*
|
|
80
|
+
* actions of the bus and returns it. Each bus has its own, so each test can
|
|
81
81
|
* have its own implementation. `handle` binds more later and returns the
|
|
82
82
|
* function that unbinds. A second `actionsPlugin` on the same bus binds its
|
|
83
83
|
* list in the registry that is there and returns it, so the order of the
|
|
84
|
-
* plugins does not matter. A `
|
|
84
|
+
* plugins does not matter. A `actions` that is not such a registry (a custom
|
|
85
85
|
* runner) is replaced.
|
|
86
86
|
*
|
|
87
|
-
* What the bus runs for
|
|
88
|
-
*
|
|
87
|
+
* What the bus runs for an action: the handler bound last, else the one the
|
|
88
|
+
* action was created with, else it throws `No handler for action "..."`.
|
|
89
89
|
*
|
|
90
90
|
* @example
|
|
91
91
|
* ```ts
|
|
92
92
|
* const bus = createBus<Events>();
|
|
93
|
-
* const
|
|
93
|
+
* const actions = bus.use(actionsPlugin([setHandler(sendMail, smtpSend)]));
|
|
94
94
|
*
|
|
95
|
-
* const unbind =
|
|
96
|
-
* unbind(); // the
|
|
95
|
+
* const unbind = actions.handle(getUser, async () => fakeUser);
|
|
96
|
+
* unbind(); // the action's own handler is back
|
|
97
97
|
* ```
|
|
98
98
|
*/
|
|
99
99
|
export declare const actionsPlugin: <E extends EventMap>(bindings?: readonly Binding<E>[]) => (bus: Bus<E>) => Registry$1<E>;
|
|
100
100
|
//#endregion
|
|
101
101
|
//#region src/actions/action.d.ts
|
|
102
102
|
type Reserved = "handle" | "prepare";
|
|
103
|
-
type Made<P, T extends string> = [P] extends [Free] ? FreeActionCreator<T> : [P] extends [Call<infer Q, infer R>] ?
|
|
103
|
+
type Made<P, T extends string> = [P] extends [Free] ? FreeActionCreator<T> : [P] extends [Call<infer Q, infer R>] ? MadeHandled<Q, R, T> : ActionCreator<P, T>;
|
|
104
104
|
type ScopedCreator<P, T extends string, F> = [P] extends [Free] ? FreeActionCreator<T, F> & WithScope<F> : ActionCreator<P, T, PayloadOf<P>, F> & WithScope<F>;
|
|
105
105
|
type ScopeOf<S> = Omit<S, Reserved>;
|
|
106
|
-
type
|
|
106
|
+
type PreparedHandled<P, R, T extends string, A extends unknown[], F> = ((...args: A) => ReturnType<MadeHandled<P, R, T>> & WithScope<F>) & Omit<MadeHandled<P, R, T>, never> & WithScope<F>;
|
|
107
107
|
/**
|
|
108
108
|
* Creates an action creator, as in Redux Toolkit. With a handler it makes a
|
|
109
|
-
*
|
|
109
|
+
* action: `bus.emit(getUser("1"))` runs the handler and returns its result.
|
|
110
110
|
*
|
|
111
111
|
* - `createAction("user/loaded")` needs no generics: the payload type comes
|
|
112
112
|
* from the event map of the bus that the action goes to, and the literal
|
|
@@ -150,22 +150,22 @@ type PreparedCommand<P, R, T extends string, A extends unknown[], F> = ((...args
|
|
|
150
150
|
* ```
|
|
151
151
|
*/
|
|
152
152
|
export declare function createAction<P = Free, T extends string = string>(type: T): Made<P, T>;
|
|
153
|
-
export declare function createAction<P = void, R = void, T extends string = string, E extends EventMap = EventMap>(type: T, handler: Task<P, E, R>):
|
|
153
|
+
export declare function createAction<P = void, R = void, T extends string = string, E extends EventMap = EventMap>(type: T, handler: Task<P, E, R>): MadeHandled<P, R, T>;
|
|
154
154
|
export declare function createAction<P, R, A extends unknown[], T extends string, S extends Scope = Record<never, never>>(type: T, handler: Task<P, Scoped<EventMap, ScopeOf<S>>, R>, options: {
|
|
155
155
|
prepare: (...args: A) => {
|
|
156
156
|
payload: P;
|
|
157
157
|
};
|
|
158
|
-
} & S):
|
|
158
|
+
} & S): PreparedHandled<P, R, T, A, FieldsOfScope<EventMap, ScopeOf<S>>>;
|
|
159
159
|
export declare function createAction<P, R, A extends unknown[], T extends string, S extends Scope = Record<never, never>>(type: T, options: {
|
|
160
160
|
handle: Task<P, Scoped<EventMap, ScopeOf<S>>, R>;
|
|
161
161
|
prepare: (...args: A) => {
|
|
162
162
|
payload: P;
|
|
163
163
|
};
|
|
164
|
-
} & S):
|
|
165
|
-
export declare function createAction<P, R, T extends string, S extends Scope = Record<never, never>>(type: T, handler: Task<P, Scoped<EventMap, S>, R>, scope: S):
|
|
164
|
+
} & S): PreparedHandled<P, R, T, A, FieldsOfScope<EventMap, ScopeOf<S>>>;
|
|
165
|
+
export declare function createAction<P, R, T extends string, S extends Scope = Record<never, never>>(type: T, handler: Task<P, Scoped<EventMap, S>, R>, scope: S): ScopedHandled<P, R, T, FieldsOfScope<EventMap, S>>;
|
|
166
166
|
export declare function createAction<P, R, T extends string, S extends Scope = Record<never, never>>(type: T, options: {
|
|
167
167
|
handle: Task<P, Scoped<EventMap, ScopeOf<S>>, R>;
|
|
168
|
-
} & S):
|
|
168
|
+
} & S): ScopedHandled<P, R, T, FieldsOfScope<EventMap, ScopeOf<S>>>;
|
|
169
169
|
export declare function createAction<A extends unknown[], P, T extends string, S extends Scope = Record<never, never>>(type: T, options: {
|
|
170
170
|
prepare: (...args: A) => {
|
|
171
171
|
payload: P;
|
|
@@ -223,8 +223,8 @@ type Creator = {
|
|
|
223
223
|
readonly type: string;
|
|
224
224
|
};
|
|
225
225
|
type Outcome = string | Creator;
|
|
226
|
-
/** What `createJob` returns: the
|
|
227
|
-
type Job<P, R, T extends string, S extends Outcome, F extends Outcome, PE extends Outcome = `${T}/pending`, CE extends Outcome = `${T}/cancel`> =
|
|
226
|
+
/** What `createJob` returns: the action of the job, with its four outcome creators as properties. */
|
|
227
|
+
type Job<P, R, T extends string, S extends Outcome, F extends Outcome, PE extends Outcome = `${T}/pending`, CE extends Outcome = `${T}/cancel`> = MadeHandled<P, Promise<Awaited<R> | undefined>, T> & {
|
|
228
228
|
/** Made from a string with the payload of the call as its payload, or the creator that was given. */
|
|
229
229
|
readonly pending: PE extends string ? ActionCreator<P, PE> : PE;
|
|
230
230
|
/** Made from a string with the result as its payload, or the creator that was given. */
|
|
@@ -235,13 +235,13 @@ type Job<P, R, T extends string, S extends Outcome, F extends Outcome, PE extend
|
|
|
235
235
|
readonly cancel: CE extends string ? ActionCreator<unknown, CE> : CE;
|
|
236
236
|
};
|
|
237
237
|
/**
|
|
238
|
-
* Creates a job:
|
|
238
|
+
* Creates a job: an action whose outcome is sent on as actions. When the
|
|
239
239
|
* handler starts, `job.pending(payload)` is emitted on the bus. When it
|
|
240
240
|
* succeeds, `job.success(result)` follows, and when it fails, `job.fail(error)`.
|
|
241
241
|
* When the task is aborted after it started, `job.cancel(reason)` follows
|
|
242
242
|
* instead. After `pending`, exactly one of the three closes the call. A job is
|
|
243
243
|
* made for the case where nobody waits for the result and the bus carries it
|
|
244
|
-
* on, like `createAsyncThunk` or an effector effect. It returns the
|
|
244
|
+
* on, like `createAsyncThunk` or an effector effect. It returns the action,
|
|
245
245
|
* with the four actions on it.
|
|
246
246
|
*
|
|
247
247
|
* A scope as the last argument, `{ cache, $effects: { race } }`, gives the handler
|
|
@@ -255,14 +255,14 @@ type Job<P, R, T extends string, S extends Outcome, F extends Outcome, PE extend
|
|
|
255
255
|
*
|
|
256
256
|
* `bus.emit(job(payload))` returns a promise of the result. An error of the
|
|
257
257
|
* handler always counts as handled: it goes to `job.fail` and the promise
|
|
258
|
-
* resolves with `undefined`;
|
|
258
|
+
* resolves with `undefined`; an action is the tool for a result that must reject.
|
|
259
259
|
* The actions are emitted as the task that ran the job, also for a handler bound
|
|
260
|
-
* with `
|
|
260
|
+
* with `actions.handle`. Once the task is aborted, `success` and `fail` are
|
|
261
261
|
* skipped and `cancel` is sent when the handler settles (a handler that never
|
|
262
262
|
* settles sends nothing). A call that does not start, because a policy drops it
|
|
263
263
|
* or it is aborted while it waits in a `queue`, sends none of the four. A
|
|
264
264
|
* missing handler is not an outcome: `emit` throws `MissingHandlerError`.
|
|
265
|
-
* Calling the job builds `{ type, payload }` like
|
|
265
|
+
* Calling the job builds `{ type, payload }` like an action; it does not run
|
|
266
266
|
* the handler.
|
|
267
267
|
*
|
|
268
268
|
* @example
|
|
@@ -293,23 +293,23 @@ scope?: X) => CarryingCalls<Job<P, R, T, S, F, PE, CE>, P, Promise<Awaited<R> |
|
|
|
293
293
|
//#region src/actions/module.d.ts
|
|
294
294
|
/**
|
|
295
295
|
* What a module's `setup` gets: the context of the module's task, so `on`,
|
|
296
|
-
* `emit` and `run` work as in a handler, plus `handle` to bind
|
|
296
|
+
* `emit` and `run` work as in a handler, plus `handle` to bind actions, `use`
|
|
297
297
|
* to mount sub-modules and `spawn` to start a background task. Everything the
|
|
298
298
|
* module does is undone when it is unmounted.
|
|
299
299
|
*/
|
|
300
300
|
type ModuleContext<E extends EventMap = EventMap> = Context<E> & {
|
|
301
|
-
/** Binds the handler of
|
|
302
|
-
handle<P, R>(
|
|
303
|
-
/** Also an action made without a handler: the handler answers it as it would a
|
|
301
|
+
/** Binds the handler of an action, or a list of them; undone on unmount. */
|
|
302
|
+
handle<P, R>(handled: Handled<P, R>, fn: Task<P, E, R>): UnsubscribeCallback;
|
|
303
|
+
/** Also an action made without a handler: the handler answers it as it would one made with a handler. */
|
|
304
304
|
handle<A extends {
|
|
305
305
|
readonly type: string;
|
|
306
306
|
}>(action: A, fn: LooseHandler<A, E>): UnsubscribeCallback;
|
|
307
307
|
handle(type: string, fn: Task<never, E, unknown>): UnsubscribeCallback;
|
|
308
308
|
handle(bindings: readonly Binding<E>[]): UnsubscribeCallback;
|
|
309
309
|
/**
|
|
310
|
-
* Brings sub-modules and
|
|
311
|
-
* unmounted with this one.
|
|
312
|
-
* as long as this module is mounted;
|
|
310
|
+
* Brings sub-modules and actions, in any order. A sub-module is mounted and
|
|
311
|
+
* unmounted with this one. An action is bound to the handler it carries, for
|
|
312
|
+
* as long as this module is mounted; an action that answers by itself keeps
|
|
313
313
|
* answering after the module is gone, since the handler is its own. The
|
|
314
314
|
* returned function undoes just this call, e.g. for what was added later from
|
|
315
315
|
* a listener.
|
|
@@ -331,7 +331,7 @@ type Module<E extends EventMap = EventMap> = {
|
|
|
331
331
|
readonly scope?: Scope;
|
|
332
332
|
};
|
|
333
333
|
/**
|
|
334
|
-
* Describes one domain of an app: the
|
|
334
|
+
* Describes one domain of an app: the actions it handles, the events it
|
|
335
335
|
* listens to, its sub-modules and its background tasks. The `name` shows up as
|
|
336
336
|
* the type of the module's tasks in the trace.
|
|
337
337
|
*
|
|
@@ -373,7 +373,7 @@ interface WithApp {
|
|
|
373
373
|
}
|
|
374
374
|
/** What `modulePlugin` returns. */
|
|
375
375
|
type ModuleApi<E extends EventMap = EventMap> = {
|
|
376
|
-
/** The registry of
|
|
376
|
+
/** The registry of action handlers of the bus: the one it was made with, or the app's own. */
|
|
377
377
|
actions: Registry<E>;
|
|
378
378
|
/**
|
|
379
379
|
* Mounts modules, in the order given, and returns the function that unmounts them, last
|
|
@@ -402,17 +402,17 @@ type ModuleApi<E extends EventMap = EventMap> = {
|
|
|
402
402
|
* of one of its methods. By then every plugin is on the bus, so the plugins can
|
|
403
403
|
* be used in any order. The `on`, `once` and `off` calls made in between are
|
|
404
404
|
* held and made right after the modules, so the listeners of a module stay
|
|
405
|
-
* ahead of them. The bus runs the
|
|
405
|
+
* ahead of them. The bus runs the actions that the modules bind: the registry
|
|
406
406
|
* that the bus has is used (a later `actionsPlugin` binds in it), otherwise the
|
|
407
407
|
* app attaches its own, as `app.actions`. The app is also `bus.app`.
|
|
408
408
|
*
|
|
409
409
|
* A module is known by its `name`: mounting a module whose name is taken
|
|
410
410
|
* replaces the mounted one, which is unmounted first. That is what hot reload
|
|
411
411
|
* needs (see `docs/hmr.md`): the new version of a module file mounts again and
|
|
412
|
-
* the old version goes away with its subscriptions,
|
|
412
|
+
* the old version goes away with its subscriptions, actions and tasks.
|
|
413
413
|
*
|
|
414
414
|
* Unmounting undoes everything the module did: its subscriptions, its bound
|
|
415
|
-
*
|
|
415
|
+
* actions, its sub-modules and its background tasks. `dispose` unmounts them
|
|
416
416
|
* all, and a disposed app cannot mount modules.
|
|
417
417
|
*
|
|
418
418
|
* @example
|