nanoeffects 0.19.1 → 0.21.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-HFA_LZOH.d.ts → action-creator-Bpa8BUS9.d.ts} +18 -7
- package/dist/actions.d.ts +3 -3
- package/dist/actions.js +1 -1
- package/dist/{context-types-BNcs43eY.d.ts → context-types-BKIH5a8s.d.ts} +1 -1
- package/dist/context.d.ts +2 -2
- package/dist/dev.d.ts +2 -2
- package/dist/dev.js +1 -1
- package/dist/effects.d.ts +4 -8
- package/dist/index.d.ts +2 -2
- package/dist/match.d.ts +1 -1
- package/dist/{module-DTf73Wdq.d.ts → module-B0KVDNjY.d.ts} +14 -9
- package/dist/mount-each-D54UqAhZ.js +1 -0
- package/dist/notrace/{action-creator-CbFf398i.d.ts → action-creator-D2CotugT.d.ts} +16 -7
- package/dist/notrace/actions.d.ts +14 -9
- package/dist/notrace/actions.js +1 -1
- package/dist/notrace/effects.d.ts +4 -8
- package/dist/notrace/index.d.ts +2 -2
- package/dist/notrace/{plugin-C5vIjxhR.d.ts → plugin-C6KA4dX-.d.ts} +1 -1
- package/dist/notrace/policies.d.ts +51 -6
- package/dist/notrace/policies.js +1 -1
- package/dist/notrace/redux.d.ts +1 -1
- package/dist/observable.d.ts +1 -1
- package/dist/oop.d.ts +1 -1
- package/dist/{plugin-Sy8z9IId.d.ts → plugin-D9UTzGRG.d.ts} +2 -2
- package/dist/policies.d.ts +52 -7
- package/dist/policies.js +1 -1
- package/dist/react.d.ts +9 -8
- package/dist/redux.d.ts +1 -1
- package/dist/scope.d.ts +4 -4
- package/dist/signal.d.ts +1 -1
- package/dist/state-of-C19H6BoV.d.ts +10 -0
- package/dist/trace.d.ts +1 -1
- package/dist/{types-DaZT158m.d.ts → types-CbdJKC2z.d.ts} +2 -2
- package/dist/vue.d.ts +72 -0
- package/dist/vue.js +1 -0
- package/dist/{with-policy-C_mX7S54.d.ts → with-policy-BeH8wCkX.d.ts} +1 -1
- package/docs/README.md +2 -0
- package/docs/actions.md +31 -1
- package/docs/chat-example.md +246 -0
- package/docs/migrating-from-rxjs.md +58 -1
- package/docs/package.md +1 -0
- package/docs/plugins.md +3 -3
- package/docs/policies.md +27 -0
- package/docs/query-libraries.md +2 -0
- package/docs/react.md +5 -3
- package/docs/starter.md +25 -1
- package/docs/typescript.md +14 -0
- package/docs/vue.md +96 -0
- package/llms-full.txt +517 -10
- package/llms.txt +4 -2
- package/package.json +25 -4
package/llms.txt
CHANGED
|
@@ -9,13 +9,13 @@ Rules that generated code often gets wrong:
|
|
|
9
9
|
- A handler gets the payload and a task context: `(payload, ctx)`. The context has `signal`, `emit`, `on`, `run`. Pass `ctx.signal` to `fetch`.
|
|
10
10
|
- Effects take `ctx` as the first argument: `retry(ctx, fn, options)`, `timeout(ctx, ms, fn)`, `take(ctx, "event")`.
|
|
11
11
|
- Policies wrap a handler: `bus.on("search", latest(async (query, ctx) => { ... }))`.
|
|
12
|
-
- Each part is imported from its own path: `nanoeffects` (`createBus`), `nanoeffects/policies`, `nanoeffects/effects`, `nanoeffects/actions`, `nanoeffects/redux`, `nanoeffects/observable`, `nanoeffects/react` (`reactPlugin`, adds `bus.useEmitter` and `bus.useEventState`; `usePolicy`; needs React), `nanoeffects/trace` (`createTracer`, loggers, `tracePlugin`), `nanoeffects/dev`.
|
|
12
|
+
- Each part is imported from its own path: `nanoeffects` (`createBus`), `nanoeffects/policies`, `nanoeffects/effects`, `nanoeffects/actions`, `nanoeffects/redux`, `nanoeffects/observable`, `nanoeffects/react` (`reactPlugin`, adds `bus.useEmitter` and `bus.useEventState`; `usePolicy`; needs React), `nanoeffects/vue` (`vuePlugin`, adds `bus.watchEmitter` and `bus.useEventRef`; needs Vue), `nanoeffects/trace` (`createTracer`, loggers, `tracePlugin`), `nanoeffects/dev`.
|
|
13
13
|
- `bus.emit(command(payload))` runs the command's handler and returns its result. Plain events return nothing.
|
|
14
14
|
|
|
15
15
|
## Start here
|
|
16
16
|
|
|
17
17
|
- [Guide](docs/guide.md): bus, handler context, policies, effects, commands and modules, step by step
|
|
18
|
-
- [Start a project from a template](docs/starter.md): `npm create nanoeffects` makes a Vite project (`vanilla`
|
|
18
|
+
- [Start a project from a template](docs/starter.md): `npm create nanoeffects` makes a Vite project (`vanilla`, `react`, `vue-ts`, `svelte-ts` and others, in JavaScript or TypeScript) with a bus, `debounce` and `latest`
|
|
19
19
|
- [Why nanoeffects exists](docs/motivation.md): no dependencies and no global state for SDKs and Module Federation, and why not Redux, Effector or RxJS
|
|
20
20
|
- [Package entries](docs/package.md): which import holds what
|
|
21
21
|
- [Plugins](docs/plugins.md): every plugin of a bus, what `bus.use` returns, and the order to use them in
|
|
@@ -35,6 +35,8 @@ Rules that generated code often gets wrong:
|
|
|
35
35
|
- [Connect Redux, Zustand, MobX, or Pinia](docs/stores.md): the Redux middleware and callbacks of other stores
|
|
36
36
|
- [Use nanoeffects with React Query and SWR](docs/query-libraries.md): call a command from `queryFn` or the SWR fetcher; `signalPlugin` passes the abort of the library to the task
|
|
37
37
|
- [Build a sign-up form in React](docs/react.md): a form with a username check, a submit that cannot fire twice, and retry; `useEventState` shows an event as state, `usePolicy` keeps a debounced handler between renders
|
|
38
|
+
- [Build a chat with domains, modules and a small server](docs/chat-example.md): rooms, a history under `latest`, a send under `queue` and `retry`, a search with `allSettled` and `timeout`, new messages polled with `poll`
|
|
39
|
+
- [Use nanoeffects in a Vue app](docs/vue.md): `vuePlugin` adds `watchEmitter` (a value of a component to the bus) and `useEventRef` (an event as a ref)
|
|
38
40
|
- [Context fields](docs/context.md): put a store or client on every task
|
|
39
41
|
- [Scopes](docs/scope.md): fields for one command, action, job, module or `emit`, and a way to replace them in a test
|
|
40
42
|
- [Use the bus from a class](docs/oop.md): `Emitter`, `extendBus`, `@WithBus`, `@On`, `@Once`, and `dispose()` for the subscriptions of an instance
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nanoeffects",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Cancel stale async work and fix race conditions in event handlers: a typed event bus where every handler is a task with an AbortSignal, plus latest, debounce, throttle, queue, retry, timeout and poll. About 1.4 kB gzip.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"event-bus",
|
|
@@ -126,6 +126,10 @@
|
|
|
126
126
|
"types": "./dist/react.d.ts",
|
|
127
127
|
"import": "./dist/react.js"
|
|
128
128
|
},
|
|
129
|
+
"./vue": {
|
|
130
|
+
"types": "./dist/vue.d.ts",
|
|
131
|
+
"import": "./dist/vue.js"
|
|
132
|
+
},
|
|
129
133
|
"./dev": {
|
|
130
134
|
"production": {
|
|
131
135
|
"types": "./dist/dev.d.ts",
|
|
@@ -162,11 +166,13 @@
|
|
|
162
166
|
"@reduxjs/toolkit": "^2.13.0",
|
|
163
167
|
"@size-limit/esbuild": "^14.2.0",
|
|
164
168
|
"@size-limit/file": "^14.2.0",
|
|
169
|
+
"@tanstack/react-query": "^5.105.0",
|
|
165
170
|
"@types/react": "^19.3.0",
|
|
166
171
|
"@types/react-dom": "^19.3.0",
|
|
167
172
|
"@vitejs/plugin-react": "^6.1.2",
|
|
168
173
|
"archunit": "^2.5.4",
|
|
169
174
|
"happy-dom": "^21.0.4",
|
|
175
|
+
"immer": "^10.2.0",
|
|
170
176
|
"jotai": "^3.0.1",
|
|
171
177
|
"lefthook": "2.2.1",
|
|
172
178
|
"lodash": "4.17.21",
|
|
@@ -179,9 +185,12 @@
|
|
|
179
185
|
"size-limit": "^14.2.0",
|
|
180
186
|
"tsdown": "0.23.1",
|
|
181
187
|
"typescript": "7.0.2",
|
|
188
|
+
"typescript-5": "npm:typescript@^5.9.3",
|
|
182
189
|
"unplugin-unused": "^0.6.0",
|
|
183
190
|
"vite": "^8.3.4",
|
|
184
191
|
"vitest": "5.0.5",
|
|
192
|
+
"vue": "^3.5.44",
|
|
193
|
+
"vue-tsc": "^3.3.13",
|
|
185
194
|
"webpack": "^5.112.0",
|
|
186
195
|
"zustand": "^5.0.15"
|
|
187
196
|
},
|
|
@@ -198,7 +207,7 @@
|
|
|
198
207
|
{
|
|
199
208
|
"name": "policies (all)",
|
|
200
209
|
"path": "dist/policies.js",
|
|
201
|
-
"limit": "2.
|
|
210
|
+
"limit": "2.65 kB"
|
|
202
211
|
},
|
|
203
212
|
{
|
|
204
213
|
"name": "effects (all)",
|
|
@@ -208,7 +217,7 @@
|
|
|
208
217
|
{
|
|
209
218
|
"name": "actions (all)",
|
|
210
219
|
"path": "dist/actions.js",
|
|
211
|
-
"limit": "
|
|
220
|
+
"limit": "3.02 kB"
|
|
212
221
|
},
|
|
213
222
|
{
|
|
214
223
|
"name": "match (plugin)",
|
|
@@ -253,6 +262,14 @@
|
|
|
253
262
|
],
|
|
254
263
|
"limit": "1.24 kB"
|
|
255
264
|
},
|
|
265
|
+
{
|
|
266
|
+
"name": "vue",
|
|
267
|
+
"path": "dist/vue.js",
|
|
268
|
+
"ignore": [
|
|
269
|
+
"vue"
|
|
270
|
+
],
|
|
271
|
+
"limit": "0.4 kB"
|
|
272
|
+
},
|
|
256
273
|
{
|
|
257
274
|
"name": "dev",
|
|
258
275
|
"path": "dist/dev.js",
|
|
@@ -265,11 +282,15 @@
|
|
|
265
282
|
}
|
|
266
283
|
],
|
|
267
284
|
"peerDependencies": {
|
|
268
|
-
"react": ">=18"
|
|
285
|
+
"react": ">=18",
|
|
286
|
+
"vue": ">=3.3"
|
|
269
287
|
},
|
|
270
288
|
"peerDependenciesMeta": {
|
|
271
289
|
"react": {
|
|
272
290
|
"optional": true
|
|
291
|
+
},
|
|
292
|
+
"vue": {
|
|
293
|
+
"optional": true
|
|
273
294
|
}
|
|
274
295
|
}
|
|
275
296
|
}
|