Skip to content

Commit 0986578

Browse files
committed
WIP - Thu, Jun 20 04:49 PM
1 parent 3b6445b commit 0986578

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/class-model.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,21 @@ export function register<Instance, Klass extends { new (...args: any[]): Instanc
298298
return {
299299
[hook]() {
300300
reaction(
301-
() => klass.snapshottedViews.map((sv) => (sv.options.createSnapshot ?? getSnapshot)(self[sv.property])),
302-
() => self.__incrementSnapshottedViewsEpoch(),
301+
() => {
302+
return klass.snapshottedViews.map((sv) => {
303+
const value = self[sv.property];
304+
if (sv.options.createSnapshot) {
305+
return sv.options.createSnapshot(value);
306+
}
307+
if (Array.isArray(value)) {
308+
return value.map(getSnapshot);
309+
}
310+
return getSnapshot(value);
311+
});
312+
},
313+
() => {
314+
self.__incrementSnapshottedViewsEpoch();
315+
},
303316
{ equals: comparer.structural },
304317
);
305318
},

0 commit comments

Comments
 (0)