Function: attachToEngine()
August 8, 2026 ยท View on GitHub
@plures/praxis / index / attachToEngine
Function: attachToEngine()
attachToEngine<
TContext>(store,engine):UnsubscribeFn
Defined in: src/integrations/pluresdb.ts:247
Attach a PraxisDBStore to a LogicEngine
This function creates a bidirectional connection between the store and engine:
- Events processed by the engine are persisted to the store
- Facts from the store are synchronized to the engine
Type Parameters
TContext
TContext = unknown
Parameters
store
PraxisDBStore<TContext>
The PraxisDBStore instance
engine
LogicEngine<TContext>
The LogicEngine instance
Returns
Cleanup function to detach the store
Example
const db = createInMemoryDB();
const registry = new PraxisRegistry();
const store = createPraxisDBStore(db, registry);
const engine = createPraxisEngine({ initialContext: {}, registry });
const detach = attachToEngine(store, engine);
// Events are now automatically persisted
engine.step([{ tag: "LOGIN", payload: { username: "alice" } }]);
// Cleanup
detach();