@hypen-space/core 0.4.950 → 0.4.951
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 +8 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,10 +91,9 @@ const counter = app
|
|
|
91
91
|
const engine = new Engine();
|
|
92
92
|
await engine.init();
|
|
93
93
|
|
|
94
|
-
// 3.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
94
|
+
// 3. Mount a renderer (one call wires up patch streaming + actions)
|
|
95
|
+
import { createHypenClient } from "@hypen-space/web/dom";
|
|
96
|
+
const { renderer } = createHypenClient(document.getElementById("app")!, engine);
|
|
98
97
|
|
|
99
98
|
// 4. Register the module and render
|
|
100
99
|
engine.setModule("counter", counter.actions, counter.stateKeys, counter.initialState);
|
|
@@ -310,8 +309,12 @@ const remote = new RemoteEngine("ws://localhost:3000", {
|
|
|
310
309
|
autoReconnect: true,
|
|
311
310
|
});
|
|
312
311
|
|
|
312
|
+
// Mount a renderer once — `createHypenClient` accepts RemoteEngine
|
|
313
|
+
// directly (it picks up `onPatches` automatically).
|
|
314
|
+
import { createHypenClient } from "@hypen-space/web/dom";
|
|
315
|
+
createHypenClient(document.getElementById("app")!, remote);
|
|
316
|
+
|
|
313
317
|
remote
|
|
314
|
-
.onPatches((patches) => renderer.applyPatches(patches))
|
|
315
318
|
.onStateUpdate((state) => console.log("Server state:", state))
|
|
316
319
|
.onConnect(() => console.log("Connected"));
|
|
317
320
|
|