effect-machine 0.14.0 → 0.15.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/README.md +5 -2
- package/dist/actor.d.ts +13 -4
- package/dist/actor.js +91 -55
- package/dist/cluster/entity-machine.js +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/internal/runtime.d.ts +20 -1
- package/dist/internal/runtime.js +60 -47
- package/dist/machine.d.ts +37 -30
- package/dist/machine.js +5 -5
- package/dist/schema.d.ts +3 -1
- package/dist/schema.js +1 -0
- package/package.json +1 -1
- package/v3/dist/actor.d.ts +10 -4
- package/v3/dist/actor.js +80 -50
- package/v3/dist/cluster/entity-machine.js +1 -0
- package/v3/dist/index.d.ts +2 -2
- package/v3/dist/internal/runtime.d.ts +20 -1
- package/v3/dist/internal/runtime.js +60 -47
- package/v3/dist/machine.d.ts +37 -30
- package/v3/dist/machine.js +5 -5
package/v3/dist/machine.js
CHANGED
|
@@ -395,11 +395,11 @@ const make = Machine.make;
|
|
|
395
395
|
* slots: { canRetry: ({ max }) => attempts < max },
|
|
396
396
|
* });
|
|
397
397
|
*
|
|
398
|
-
* // With
|
|
398
|
+
* // With lifecycle (recovery + durability)
|
|
399
399
|
* const actor = yield* Machine.spawn(machine, {
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
* save: (
|
|
400
|
+
* lifecycle: {
|
|
401
|
+
* recovery: { resolve: ({ machineInitial }) => storage.get("actor-state") },
|
|
402
|
+
* durability: { save: ({ nextState }) => storage.set("actor-state", nextState) },
|
|
403
403
|
* },
|
|
404
404
|
* });
|
|
405
405
|
* ```
|
|
@@ -409,7 +409,7 @@ const spawn = Effect.fn("effect-machine.spawn")(function* (machine, idOrOptions)
|
|
|
409
409
|
const actor = yield* createActor(opts?.id ?? `actor-${(yield* Random.next).toString(36).slice(2)}`, materializeMachine(machine, opts?.slots), {
|
|
410
410
|
initialState: opts?.hydrate,
|
|
411
411
|
supervision: opts?.supervision,
|
|
412
|
-
|
|
412
|
+
lifecycle: opts?.lifecycle
|
|
413
413
|
});
|
|
414
414
|
const maybeScope = yield* Effect.serviceOption(Scope.Scope);
|
|
415
415
|
if (Option.isSome(maybeScope)) yield* Scope.addFinalizer(maybeScope.value, actor.stop);
|