Skip to content

Commit 57d71b5

Browse files
committed
feat: add injectBeforeRender
1 parent 54901e7 commit 57d71b5

File tree

8 files changed

+18352
-13601
lines changed

8 files changed

+18352
-13601
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"singleQuote": true,
33
"tabWidth": 4,
4-
"printWidth": 120
4+
"printWidth": 120,
5+
"plugins": ["prettier-plugin-organize-imports"]
56
}

apps/demo/src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ import { RouterOutlet } from '@angular/router';
77
template: ` <router-outlet />`,
88
imports: [RouterOutlet],
99
})
10-
export class AppComponent { }
10+
export class AppComponent {}

libs/angular-three/src/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
export * from './lib/canvas';
2-
export * from './lib/types';
2+
export * from './lib/di/before-render';
33
export * from './lib/di/catalogue';
4+
export * from './lib/di/destroy';
5+
export * from './lib/di/ref';
46
export * from './lib/directives/args';
57
export * from './lib/directives/repeat';
6-
export * from './lib/stores/store';
8+
export * from './lib/loader';
9+
export * from './lib/pipes/push';
710
export * from './lib/stores/rx-store';
11+
export * from './lib/stores/store';
12+
export * from './lib/types';
813
export * from './lib/utils/instance';
9-
export * from './lib/utils/update';
1014
export * from './lib/utils/is';
11-
export * from './lib/loader';
12-
export * from './lib/di/ref';
13-
export * from './lib/di/destroy';
14-
export * from './lib/pipes/push';
15+
export * from './lib/utils/update';

libs/angular-three/src/lib/canvas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ import {
1818
} from '@angular/core';
1919
import { injectNgxResize, NgxResizeResult, provideNgxResizeOptions } from 'ngx-resize';
2020
import { filter } from 'rxjs';
21+
import { injectNgtLoader } from './loader';
2122
import { provideNgtRenderer } from './renderer/provider';
2223
import { NgtRxStore } from './stores/rx-store';
2324
import { NgtStore, rootStateMap } from './stores/store';
2425
import type { NgtCanvasInputs, NgtDomEvent, NgtDpr, NgtState } from './types';
2526
import { is } from './utils/is';
2627
import { createPointerEvents } from './web/events';
27-
import { injectNgtLoader } from './loader';
2828

2929
@Component({
3030
selector: 'ngt-canvas-container',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { inject } from '@angular/core';
2+
import { NgtStore } from '../stores/store';
3+
import { NgtBeforeRenderRecord } from '../types';
4+
import { injectNgtDestroy } from './destroy';
5+
6+
export function injectBeforeRender(cb: NgtBeforeRenderRecord['callback'], priority = 0) {
7+
try {
8+
const store = inject(NgtStore);
9+
const sub = store.get('internal').subscribe((state) => cb(state), priority, store);
10+
injectNgtDestroy(() => void sub());
11+
return sub;
12+
} catch (e) {
13+
throw new Error(`[NGT] "injectBeforeRender" is invoked outside of Constructor Context`);
14+
}
15+
}

libs/angular-three/src/lib/loader.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import {
2+
catchError,
3+
forkJoin,
4+
from,
25
isObservable,
6+
map,
37
Observable,
48
of,
5-
map,
6-
tap,
7-
from,
9+
ReplaySubject,
810
retry,
911
share,
10-
ReplaySubject,
11-
catchError,
1212
switchMap,
13-
forkJoin,
1413
take,
14+
tap,
1515
} from 'rxjs';
1616
import type { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
1717
import type { NgtBranchingReturn, NgtLoaderExtensions, NgtLoaderResult, NgtObjectMap } from './types';

package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
},
88
"private": true,
99
"devDependencies": {
10-
"@angular-devkit/build-angular": "~15.1.0",
10+
"@angular-devkit/build-angular": "~15.1.2",
1111
"@angular-eslint/eslint-plugin": "~15.0.0",
1212
"@angular-eslint/eslint-plugin-template": "~15.0.0",
1313
"@angular-eslint/template-parser": "~15.0.0",
14-
"@angular/cli": "~15.1.0",
15-
"@angular/compiler-cli": "~15.1.0",
16-
"@angular/language-service": "~15.1.0",
14+
"@angular/cli": "~15.1.2",
15+
"@angular/compiler-cli": "~15.1.1",
16+
"@angular/language-service": "~15.1.1",
1717
"@nrwl/angular": "15.5.2",
1818
"@nrwl/eslint-plugin-nx": "15.5.2",
1919
"@nrwl/jest": "15.5.2",
@@ -24,17 +24,17 @@
2424
"@types/jest": "28.1.1",
2525
"@types/node": "16.11.7",
2626
"@types/three": "^0.148.0",
27-
"@typescript-eslint/eslint-plugin": "^5.36.1",
28-
"@typescript-eslint/parser": "^5.36.1",
27+
"@typescript-eslint/eslint-plugin": "^5.48.2",
28+
"@typescript-eslint/parser": "^5.48.2",
2929
"dotenv-cli": "^7.0.0",
3030
"eslint": "~8.15.0",
3131
"eslint-config-prettier": "8.1.0",
3232
"jest": "28.1.1",
3333
"jest-environment-jsdom": "28.1.1",
34-
"jest-preset-angular": "~12.2.3",
35-
"ng-packagr": "~15.1.0",
34+
"jest-preset-angular": "~12.2.5",
35+
"ng-packagr": "~15.1.1",
3636
"nx": "15.5.2",
37-
"postcss": "^8.4.5",
37+
"postcss": "^8.4.21",
3838
"postcss-import": "~14.1.0",
3939
"postcss-preset-env": "~7.5.0",
4040
"postcss-url": "~10.1.3",
@@ -46,20 +46,20 @@
4646
"typescript": "~4.9.4"
4747
},
4848
"dependencies": {
49-
"@angular/animations": "~15.1.0",
50-
"@angular/common": "~15.1.0",
51-
"@angular/compiler": "~15.1.0",
52-
"@angular/core": "~15.1.0",
53-
"@angular/forms": "~15.1.0",
54-
"@angular/platform-browser": "~15.1.0",
55-
"@angular/platform-browser-dynamic": "~15.1.0",
56-
"@angular/router": "~15.1.0",
49+
"@angular/animations": "~15.1.1",
50+
"@angular/common": "~15.1.1",
51+
"@angular/compiler": "~15.1.1",
52+
"@angular/core": "~15.1.1",
53+
"@angular/forms": "~15.1.1",
54+
"@angular/platform-browser": "~15.1.1",
55+
"@angular/platform-browser-dynamic": "~15.1.1",
56+
"@angular/router": "~15.1.1",
5757
"@rx-angular/state": "^1.7.0",
5858
"ngx-resize": "^1.0.4",
59-
"rxjs": "~7.5.0",
59+
"rxjs": "~7.5.7",
6060
"three": "^0.148.0",
6161
"three-stdlib": "^2.21.5",
62-
"tslib": "^2.3.0",
63-
"zone.js": "~0.11.4"
62+
"tslib": "^2.4.1",
63+
"zone.js": "~0.11.8"
6464
}
6565
}

0 commit comments

Comments
 (0)