Skip to content

Commit 3702fcd

Browse files
committed
Track each snapshottedView individually
1 parent 48c5542 commit 3702fcd

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/class-model.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,24 +298,24 @@ export function register<Instance, Klass extends { new (...args: any[]): Instanc
298298
const hook = isRoot(self) ? "afterCreate" : "afterAttach";
299299
return {
300300
[hook]() {
301-
reaction(
302-
() => {
303-
return klass.snapshottedViews.map((sv) => {
304-
const value = self[sv.property];
305-
if (sv.options.createSnapshot) {
306-
return sv.options.createSnapshot(value);
301+
for (const view of klass.snapshottedViews) {
302+
reaction(
303+
() => {
304+
const value = self[view.property];
305+
if (view.options.createSnapshot) {
306+
return view.options.createSnapshot(value);
307307
}
308308
if (Array.isArray(value)) {
309309
return value.map(getSnapshot);
310310
}
311311
return getSnapshot(value);
312-
});
313-
},
314-
() => {
315-
self.__incrementSnapshottedViewsEpoch();
316-
},
317-
{ equals: comparer.structural },
318-
);
312+
},
313+
() => {
314+
self.__incrementSnapshottedViewsEpoch();
315+
},
316+
{ equals: comparer.structural },
317+
);
318+
}
319319
},
320320
};
321321
});

0 commit comments

Comments
 (0)