You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The name `Router` is overloaded with URL-routing terminology in the web
ecosystem. This renames the central dispatch class to `EventBus` — a
name that accurately reflects its role as an event-driven state bus.
Breaking changes
- `Router` → `EventBus`
- `router` variable convention → `bus`
- `RouterContext` → `EventBusContext`
- `EspRouterContextProvider` → `EspEventBusContextProvider`
- `RouterProvider` → `EventBusProvider`
- `useRouter()` → `useEventBus()`
- `ConnectableComponentChildProps.router` → `.bus`
- `src/router/` → `src/eventBus/`
- `tests/router/` → `tests/eventBus/`
- `espRouterContextProvider.tsx` → `espEventBusContextProvider.tsx`
- `routerSpy.ts` → `eventBusSpy.ts`
- Error messages, DevTools labels, and Logger names updated throughout
Copy file name to clipboardExpand all lines: CLAUDE.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,15 @@
2
2
3
3
## Project Overview
4
4
5
-
ESP is a TypeScript/JavaScript framework for managing model state changes in a deterministic, event-driven manner. A central `Router` sits between event publishers and models: publishers call `router.publishEvent(modelId, eventType, event)`, the router queues and dispatches events through ordered observation stages, and a frozen immutable snapshot of the mutated model is then pushed to model observers. The framework uses an immer-based functional modeling pattern (`ModelBuilder`) and is designed for complex composite single-page applications.
5
+
ESP is a TypeScript/JavaScript framework for managing model state changes in a deterministic, event-driven manner. A central `EventBus` sits between event publishers and models: publishers call `bus.publishEvent(modelId, eventType, event)`, the bus queues and dispatches events through ordered observation stages, and a frozen immutable snapshot of the mutated model is then pushed to model observers. The framework uses an immer-based functional modeling pattern (`ModelBuilder`) and is designed for complex composite single-page applications.
6
6
7
-
The monorepo contains the core router, dependency injection container, and React integration.
7
+
The monorepo contains the core event bus, dependency injection container, and React integration.
8
8
9
9
## Monorepo Structure
10
10
11
11
```
12
12
packages/
13
-
esp-js # Core event router — foundational, no dependencies on other esp-* packages
13
+
esp-js # Core event bus — foundational, no dependencies on other esp-* packages
14
14
esp-js-di # Standalone IoC container (JavaScript, not TypeScript)
15
15
esp-js-react # React bindings (ConnectableComponent, hooks); depends on esp-js
16
16
```
@@ -105,27 +105,27 @@ npm run test-ci # vitest run (no watch, CI mode)
2.EventBus drains the queue, dispatching each event through four sequential observation stages:
112
112
-`preview` — observe before mutation; can cancel the event
113
113
-`normal` — primary mutation stage
114
114
-`committed` — only fires if `eventContext.commit()` was called during `normal`
115
115
-`final` — fires regardless of commit; observe after all mutation
116
-
3. After all events for a model are processed, a frozen immutable snapshot of the model is pushed to model observers (`router.getModelObservable(modelId)`)
116
+
3. After all events for a model are processed, a frozen immutable snapshot of the model is pushed to model observers (`bus.getModelObservable(modelId)`)
117
117
118
118
### Functional model pattern (esp-js core)
119
119
120
120
- Create a plain object or class instance as the initial state
121
-
- Register with `router.modelBuilder(modelId, initialState).withEventHandler(...).build()`
122
-
- Event handlers receive an immer `draft` — mutate it directly; the router produces a new frozen snapshot after all handlers run
121
+
- Register with `bus.modelBuilder(modelId, initialState).withEventHandler(...).build()`
122
+
- Event handlers receive an immer `draft` — mutate it directly; the bus produces a new frozen snapshot after all handlers run
123
123
- Preview handlers and effect handlers receive `Readonly<TModel>` (no draft)
124
124
- Class instances used as model state must include `[immerable] = true` (from `immer`) for immer to handle them
125
125
126
126
### React integration (esp-js-react)
127
127
128
-
-`<EspRouterContextProvider router={router}>` — provides router via context
128
+
-`<EspEventBusContextProvider bus={bus}>` — provides bus via context
129
129
-`ConnectableComponent` / `connect()` — subscribes to a model by `modelId`, re-renders on model updates; requires explicit `view` prop
130
130
-`useSyncModelWithSelector` — hook-based subscription with selector and equality function
Copy file name to clipboardExpand all lines: README.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@ ESP gives you the ability to manage changes to a model in a deterministic event
8
8
It does this by adding specific processing workflow around changes to a model's state.
9
9
It was born out of the need to manage complex UI and/or server state.
10
10
11
-
At its core is a `Router` which sits between event publishers and the model.
12
-
Those wanting to change the model publish events to the `Router`.
11
+
At its core is a `EventBus` which sits between event publishers and the model.
12
+
Those wanting to change the model publish events to the `EventBus`.
13
13
The model observes the events and applies the changes.
14
14
The model is then dispatched to model observers so new state can be applied.
15
15
It's lightweight, easy to apply and puts the model at the forefront of your design.
@@ -18,11 +18,9 @@ ESP 2.0 adds a host of other additional libraries to help you build composite si
18
18
It allows you to use either OO, and/or immutable pattens (Redux like) for modeling independent and decoupled screens within your composite application.
19
19
Features include:
20
20
21
-
* The core event router - esp-js [](https://www.npmjs.com/package/esp-js)
21
+
* The core EventBus - esp-js [](https://www.npmjs.com/package/esp-js)
Copy file name to clipboardExpand all lines: packages/esp-js-di/README.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@ ESP gives you the ability to manage changes to a model in a deterministic event
8
8
It does this by adding specific processing workflow around changes to a model's state.
9
9
It was born out of the need to manage complex UI and/or server state.
10
10
11
-
At its core is a `Router` which sits between event publishers and the model.
12
-
Those wanting to change the model publish events to the `Router`.
11
+
At its core is a `EventBus` which sits between event publishers and the model.
12
+
Those wanting to change the model publish events to the `EventBus`.
13
13
The model observes the events and applies the changes.
14
14
The model is then dispatched to model observers so new state can be applied.
15
15
It's lightweight, easy to apply and puts the model at the forefront of your design.
@@ -18,11 +18,9 @@ ESP 2.0 adds a host of other additional libraries to help you build composite si
18
18
It allows you to use either OO, and/or immutable pattens (Redux like) for modeling independent and decoupled screens within your composite application.
19
19
Features include:
20
20
21
-
* The core event router - esp-js [](https://www.npmjs.com/package/esp-js)
21
+
* The core EventBus - esp-js [](https://www.npmjs.com/package/esp-js)
Copy file name to clipboardExpand all lines: packages/esp-js-react/CLAUDE.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Package Purpose
4
4
5
-
React bindings for ESP. Provides two complementary integration approaches: the `ConnectableComponent`/`connect()` HOC pattern and the `useSyncModelWithSelector` hook. Also provides React context providers for the `Router` and model.
5
+
React bindings for ESP. Provides two complementary integration approaches: the `ConnectableComponent`/`connect()` HOC pattern and the `useSyncModelWithSelector` hook. Also provides React context providers for the `EventBus` and model.
6
6
7
7
## Role in Monorepo
8
8
@@ -27,29 +27,29 @@ Note: the Vite entry and output filename is `esp-react` (see `vite.config.ts`),
27
27
28
28
```
29
29
src/
30
-
index.ts # Public exports
31
-
connectableComponent.tsx # ConnectableComponent — HOC that subscribes to router model
`ConnectableComponent` subscribes to `router.getModelObservable(modelId)` and re-renders when the model updates.
70
+
`ConnectableComponent` subscribes to `bus.getModelObservable(modelId)` and re-renders when the model updates.
71
71
72
72
### useSyncModelWithSelector
73
73
74
-
Hook-based approach using React 18's `useSyncExternalStore`. The model emitted by the router is always a frozen immutable snapshot (produced by immer via `ModelBuilder`) — no unwrapping required.
74
+
Hook-based approach using React 18's `useSyncExternalStore`. The model emitted by the bus is always a frozen immutable snapshot (produced by immer via `ModelBuilder`) — no unwrapping required.
- Uses `@testing-library/react` for rendering and interaction
123
-
-`tests/testApi/` — shared test fixtures including mock router and model helpers
124
-
-`testModel.ts` — `createTestModel(router, modelId)` registers a model via `ModelBuilder`
123
+
-`tests/testApi/` — shared test fixtures including mock bus and model helpers
124
+
-`testModel.ts` — `createTestModel(bus, modelId)` registers a model via `ModelBuilder`
125
125
-`testApi.tsx` — `setupTestModel(modelId)` and `setupModel(modelId, model)` helpers
126
-
-`routerSpy.ts` — `RouterSpy extends Router`, wraps `getModelObservable()` to count subscriptions (does **not** use `Observable.create` — reactive module is internal)
126
+
-`eventBusSpy.ts` — `EventBusSpy extends EventBus`, wraps `getModelObservable()` to count subscriptions (does **not** use `Observable.create` — reactive module is internal)
127
127
- Notable test files:
128
128
-`connectableComponentTests.tsx` — HOC subscription and re-render behaviour; models use `[immerable] = true`
129
129
-`useSyncModelWithSelectorTests.tsx` — hook selector and equality function behaviour
130
-
-`espModelContextProviderTests.tsx`, `espRouterContextProviderTests.tsx` — context hook tests; use `router.getModel()` to read current snapshot after events
130
+
-`espModelContextProviderTests.tsx`, `espEventBusContextProviderTests.tsx` — context hook tests; use `bus.getModel()` to read current snapshot after events
Copy file name to clipboardExpand all lines: packages/esp-js-react/README.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@ ESP gives you the ability to manage changes to a model in a deterministic event
8
8
It does this by adding specific processing workflow around changes to a model's state.
9
9
It was born out of the need to manage complex UI and/or server state.
10
10
11
-
At its core is a `Router` which sits between event publishers and the model.
12
-
Those wanting to change the model publish events to the `Router`.
11
+
At its core is a `EventBus` which sits between event publishers and the model.
12
+
Those wanting to change the model publish events to the `EventBus`.
13
13
The model observes the events and applies the changes.
14
14
The model is then dispatched to model observers so new state can be applied.
15
15
It's lightweight, easy to apply and puts the model at the forefront of your design.
@@ -18,11 +18,9 @@ ESP 2.0 adds a host of other additional libraries to help you build composite si
18
18
It allows you to use either OO, and/or immutable pattens (Redux like) for modeling independent and decoupled screens within your composite application.
19
19
Features include:
20
20
21
-
* The core event router - esp-js [](https://www.npmjs.com/package/esp-js)
21
+
* The core EventBus- esp-js [](https://www.npmjs.com/package/esp-js)
0 commit comments