Skip to content

Commit cdf0637

Browse files
committed
fix: allow prepare to accept a synchronous function to calculate the instance
1 parent 04fffae commit cdf0637

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libs/angular-three/src/lib/utils/instance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export function invalidateInstance<TInstance extends object>(instance: TInstance
1616
}
1717

1818
export function prepare<TInstance extends object = NgtAnyRecord>(
19-
object: TInstance,
19+
object: TInstance | (() => TInstance),
2020
localState?: Partial<NgtInstanceLocalState>
2121
): NgtInstanceNode<TInstance> {
22-
const instance = object as unknown as NgtInstanceNode<TInstance>;
22+
const instance = (typeof object === 'function' ? object() : object) as unknown as NgtInstanceNode<TInstance>;
2323

2424
if (localState?.primitive || !instance.__ngt__) {
2525
const {

0 commit comments

Comments
 (0)