Skip to content

Commit 882f7d9

Browse files
committed
feat: add createAttachFunction for aid with attach input as function
1 parent b65bcea commit 882f7d9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

libs/angular-three/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export * from './lib/pipes/push';
1010
export * from './lib/stores/rx-store';
1111
export * from './lib/stores/store';
1212
export * from './lib/types';
13+
export { createAttachFunction } from './lib/utils/attach';
1314
export * from './lib/utils/instance';
1415
export * from './lib/utils/is';
1516
export * from './lib/utils/update';

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { NgtAnyRecord, NgtAttachFunction } from '../types';
1+
import { NgtRxStore } from '../stores/rx-store';
2+
import type { NgtAnyRecord, NgtAttachFunction, NgtState } from '../types';
23
import { applyProps } from './apply-props';
34
import { getLocalState } from './instance';
45

@@ -28,3 +29,9 @@ function assignEmpty(obj: NgtAnyRecord, base: string) {
2829
obj[base] = {};
2930
}
3031
}
32+
33+
export function createAttachFunction<TParent = any, TChild = any>(
34+
cb: (params: { parent: TParent; child: TChild; store: NgtRxStore<NgtState> }) => (() => void) | void
35+
): NgtAttachFunction<TChild, TParent> {
36+
return (parent, child, store) => cb({ parent, child, store });
37+
}

0 commit comments

Comments
 (0)