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.
@@ -395,11 +395,11 @@ const make = Machine.make;
395
395
  * slots: { canRetry: ({ max }) => attempts < max },
396
396
  * });
397
397
  *
398
- * // With persistence
398
+ * // With lifecycle (recovery + durability)
399
399
  * const actor = yield* Machine.spawn(machine, {
400
- * persist: {
401
- * load: () => storage.get("actor-state"),
402
- * save: (state) => storage.set("actor-state", state),
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
- persist: opts?.persist
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);