Skip to content

Commit

Permalink
(refactor): local injector
Browse files Browse the repository at this point in the history
  • Loading branch information
viacheslav.sotsenko committed Apr 3, 2023
1 parent 5fba0bd commit 2989638
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 10,042 deletions.
10,037 changes: 3 additions & 10,034 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@angular/router": "^15.0.4",
"marked": "^4.2.5",
"ngx-base-state": "^1.0.2",
"ngx-local-injector": "^1.0.2",
"prismjs": "^1.29.0",
"rxjs": "^7.8.0",
"tslib": "^2.4.1",
Expand Down
2 changes: 1 addition & 1 deletion src/app/library/core/classes/base-components/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export abstract class ɵOsBaseOptionComponent<T> extends ɵOsBaseViewComponent {

/** Fires when the option item selected */
@Output()
public readonly abstract osSelected: EventEmitter<unknown>;
public readonly abstract osSelected: EventEmitter<any>;
}
4 changes: 2 additions & 2 deletions src/app/library/core/classes/base-components/view.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Directive } from '@angular/core';
import { injectLocal } from 'ngx-local-injector';
import { ɵInjectLocal } from '../../helpers';
import { ɵDestroyService } from '../../services';

@Directive({
Expand All @@ -8,5 +8,5 @@ import { ɵDestroyService } from '../../services';
}
})
export abstract class ɵOsBaseViewComponent {
protected viewDestroyed$ = injectLocal(ɵDestroyService);
protected viewDestroyed$ = ɵInjectLocal(ɵDestroyService);
}
1 change: 1 addition & 0 deletions src/app/library/core/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './element-resizing-observer.helper';
export * from './error.helper';
export * from './event-outside.helper';
export * from './id-generator.helper';
export * from './inject-local.helper';
export * from './interval-checker.helper';
export * from './methods.helper';
export * from './percents.helper';
Expand Down
13 changes: 13 additions & 0 deletions src/app/library/core/helpers/inject-local.helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { AbstractType, InjectionToken, Injector, Type, inject } from '@angular/core';

type ProviderToken<T> = Type<T> | AbstractType<T> | InjectionToken<T>;

export function ɵInjectLocal<T>(token: ProviderToken<T>): T {
const parentInjector = inject(Injector);
const localInjector = Injector.create({
providers: [token as any],
parent: parentInjector
});

return localInjector.get<T>(token);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ViewEncapsulation
} from '@angular/core';
import { ɵOsBaseViewComponent } from '../../../../core';
import { TreeViewNodeDirective } from '../../directives';
import { TreeViewNodeDirective } from '../../directives/node.directive';
import { ɵNodeTemplateContext } from '../../interfaces';
import {
TreeNodesExpansionService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
OsComponentEnum,
OsComponentOverviewSectionEnum as RouteEnum
} from '@features/documentation';
import { injectLocal } from 'ngx-local-injector';
import { ɵDestroyService } from 'ngx-os/core';
import { ɵDestroyService, ɵInjectLocal } from 'ngx-os/core';
import { Observable } from 'rxjs';
import { filter, map, takeUntil } from 'rxjs/operators';
import { SideBarItem } from './side-bar-item.interface';
Expand All @@ -33,7 +32,7 @@ export class SideBarItemsService {
}
];

private readonly destroyed$ = injectLocal(ɵDestroyService);
private readonly destroyed$ = ɵInjectLocal(ɵDestroyService);

private currentRoute: string;

Expand Down

0 comments on commit 2989638

Please sign in to comment.