Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 59f0dda

Browse files
committed
fix(core): adjust nested effects
1 parent cf4baaf commit 59f0dda

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

libs/core/src/lib/canvas.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,10 @@ export class NgtCanvas implements OnInit, OnChanges {
262262
this.zone.runOutsideAngular(() => {
263263
if (!this.configurator) this.configurator = this.initRoot(this.glCanvas.nativeElement);
264264
this.configurator.configure({ ...inputs(), size: result });
265+
this.configurator.startInvalidate();
265266

266267
if (this.glRef) {
267-
this.cdr.detectChanges();
268+
safeDetectChanges(this.cdr);
268269
} else {
269270
this.render();
270271
}
@@ -346,7 +347,7 @@ export class NgtCanvas implements OnInit, OnChanges {
346347
for (const [key, value] of Object.entries(this.sceneGraphInputs)) {
347348
this.glRef.setInput(key, value);
348349
}
349-
this.glRef.changeDetectorRef.detectChanges();
350+
safeDetectChanges(this.glRef.changeDetectorRef);
350351
}
351352
});
352353
}

libs/core/src/lib/renderer/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export class NgtRendererStore {
236236
return;
237237
}
238238

239-
const parent = getLocalState(node).parent() || rS[NgtRendererClassId.parent];
239+
const parent = untracked(getLocalState(node).parent) || rS[NgtRendererClassId.parent];
240240

241241
// [rawValue]
242242
if (getLocalState(node).isRaw && name === SPECIAL_PROPERTIES.VALUE) {

libs/core/src/lib/roots.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,13 @@ export function injectCanvasRootInitializer(injector?: Injector) {
261261
if (state.frameloop !== frameloop) state.setFrameloop(frameloop);
262262

263263
isConfigured = true;
264-
264+
},
265+
startInvalidate: () => {
265266
invalidateRef?.destroy();
266-
invalidateRef = effect(() => void store.state().invalidate(), { manualCleanup: true, injector });
267+
return (invalidateRef = effect(() => void store.state().invalidate(), {
268+
manualCleanup: true,
269+
injector,
270+
}));
267271
},
268272
};
269273
};

0 commit comments

Comments
 (0)