We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a091aca commit e2fb313Copy full SHA for e2fb313
libs/angular-three/src/lib/utils/instance.ts
@@ -38,7 +38,14 @@ export function prepare<TInstance extends object = NgtAnyRecord>(
38
objects,
39
nonObjects,
40
add: (object, type) => {
41
- instance.__ngt__[type].next([...instance.__ngt__[type].value, object]);
+ const current = instance.__ngt__[type].value;
42
+ const foundIndex = current.indexOf((obj: NgtInstanceNode) => obj === object);
43
+ if (foundIndex > -1) {
44
+ current.splice(foundIndex, 1, object);
45
+ instance.__ngt__[type].next(current);
46
+ } else {
47
+ instance.__ngt__[type].next([...instance.__ngt__[type].value, object]);
48
+ }
49
notifyAncestors(instance.__ngt__.parent);
50
},
51
remove: (object, type) => {
0 commit comments