mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
build(spf): build26 from 45504a2b
This commit is contained in:
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
import { signal, untrack, update } from "./signals/primitives.js";
|
||||
//#region src/core/machine.ts
|
||||
/**
|
||||
* Provisions the shared mechanics for all machine-like primitives: a snapshot
|
||||
* signal, an untracked state reader, and a transition function.
|
||||
*
|
||||
* Internal — consumed by `createMachineActor` and `createMachineReactor`. Not part of the
|
||||
* public API.
|
||||
*/
|
||||
function createMachineCore(initialSnapshot) {
|
||||
const snapshotSignal = signal(initialSnapshot);
|
||||
const getState = () => untrack(() => snapshotSignal.get().value);
|
||||
const transition = (to) => update(snapshotSignal, (current) => ({
|
||||
...current,
|
||||
value: to
|
||||
}));
|
||||
return {
|
||||
snapshotSignal,
|
||||
getState,
|
||||
transition
|
||||
};
|
||||
}
|
||||
//#endregion
|
||||
export { createMachineCore };
|
||||
|
||||
//# sourceMappingURL=machine.js.map
|
||||
Reference in New Issue
Block a user