Skip to content

Commit f52b5f4

Browse files
feat(plugin-stack-persistence): pass Stack to createMetadata (#731)
1 parent d915c5f commit f52b5f4

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@stackflow/plugin-stack-persistence": minor
3+
---
4+
5+
Pass the current `Stack` to `StackSnapshotStrategy.createMetadata`, so metadata can be derived from the same stack state that the snapshot is captured from.

extensions/plugin-stack-persistence/src/StackSnapshotStrategy.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import type { StackSnapshot } from "@stackflow/core";
1+
import type { Stack, StackSnapshot } from "@stackflow/core";
22
import type { StackSnapshotRecord } from "./StackSnapshotRecord";
33

44
export interface StackSnapshotStrategy<Metadata> {
5-
createMetadata(args: {
6-
snapshot: StackSnapshot;
7-
}): Metadata;
5+
createMetadata(args: { stack: Stack; snapshot: StackSnapshot }): Metadata;
86

97
shouldReuse(args: {
108
record: StackSnapshotRecord<Metadata>;

extensions/plugin-stack-persistence/src/stackPersistencePlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function stackPersistencePlugin<Metadata>(
2424
if (stack.globalTransitionState !== "idle") return;
2525

2626
const snapshot = actions.captureSnapshot();
27-
const metadata = strategy.createMetadata({ snapshot });
27+
const metadata = strategy.createMetadata({ stack, snapshot });
2828

2929
storage.save({
3030
snapshot,

0 commit comments

Comments
 (0)