From 09d1b1034e3ba612640f531c195675389a90beda Mon Sep 17 00:00:00 2001 From: Sercan Yemen Date: Mon, 2 Jul 2018 14:30:18 +0300 Subject: [PATCH] (Fuse) Tree-shakable core services, closes #64 --- .../navigation/navigation.service.ts | 4 ++- .../components/sidebar/sidebar.service.ts | 4 ++- .../fuse-mat-sidenav.service.ts | 4 ++- src/@fuse/fuse.module.ts | 25 ++----------------- src/@fuse/services/config.service.ts | 4 ++- src/@fuse/services/copier.service.ts | 9 ++++--- src/@fuse/services/loading-bar.service.ts | 4 ++- src/@fuse/services/match-media.service.ts | 4 ++- src/@fuse/services/splash-screen.service.ts | 4 ++- .../services/translation-loader.service.ts | 4 ++- 10 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/@fuse/components/navigation/navigation.service.ts b/src/@fuse/components/navigation/navigation.service.ts index c4e05fa9..3b07b456 100644 --- a/src/@fuse/components/navigation/navigation.service.ts +++ b/src/@fuse/components/navigation/navigation.service.ts @@ -3,7 +3,9 @@ import { BehaviorSubject, Observable, Subject } from 'rxjs'; import { FuseNavigationItem } from '@fuse/types'; -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class FuseNavigationService { onItemCollapsed: Subject; diff --git a/src/@fuse/components/sidebar/sidebar.service.ts b/src/@fuse/components/sidebar/sidebar.service.ts index 180e15ec..7f6ed609 100644 --- a/src/@fuse/components/sidebar/sidebar.service.ts +++ b/src/@fuse/components/sidebar/sidebar.service.ts @@ -2,7 +2,9 @@ import { Injectable } from '@angular/core'; import { FuseSidebarComponent } from './sidebar.component'; -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class FuseSidebarService { // Private diff --git a/src/@fuse/directives/fuse-mat-sidenav/fuse-mat-sidenav.service.ts b/src/@fuse/directives/fuse-mat-sidenav/fuse-mat-sidenav.service.ts index 893c7fd4..510e0b98 100644 --- a/src/@fuse/directives/fuse-mat-sidenav/fuse-mat-sidenav.service.ts +++ b/src/@fuse/directives/fuse-mat-sidenav/fuse-mat-sidenav.service.ts @@ -1,7 +1,9 @@ import { Injectable } from '@angular/core'; import { MatSidenav } from '@angular/material'; -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class FuseMatSidenavHelperService { sidenavInstances: MatSidenav[]; diff --git a/src/@fuse/fuse.module.ts b/src/@fuse/fuse.module.ts index c25a483e..c942f0e8 100644 --- a/src/@fuse/fuse.module.ts +++ b/src/@fuse/fuse.module.ts @@ -1,29 +1,8 @@ import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core'; -import { FUSE_CONFIG, FuseConfigService } from '@fuse/services/config.service'; -import { FuseCopierService } from '@fuse/services/copier.service'; -import { FuseLoadingBarService } from '@fuse/services/loading-bar.service'; -import { FuseMatchMediaService } from '@fuse/services/match-media.service'; -import { FuseMatSidenavHelperService } from '@fuse/directives/fuse-mat-sidenav/fuse-mat-sidenav.service'; -import { FuseNavigationService } from '@fuse/components/navigation/navigation.service'; -import { FuseSidebarService } from '@fuse/components/sidebar/sidebar.service'; -import { FuseSplashScreenService } from '@fuse/services/splash-screen.service'; -import { FuseTranslationLoaderService } from '@fuse/services/translation-loader.service'; +import { FUSE_CONFIG } from '@fuse/services/config.service'; -@NgModule({ - entryComponents: [], - providers : [ - FuseConfigService, - FuseCopierService, - FuseLoadingBarService, - FuseMatchMediaService, - FuseMatSidenavHelperService, - FuseNavigationService, - FuseSidebarService, - FuseSplashScreenService, - FuseTranslationLoaderService - ] -}) +@NgModule() export class FuseModule { constructor(@Optional() @SkipSelf() parentModule: FuseModule) diff --git a/src/@fuse/services/config.service.ts b/src/@fuse/services/config.service.ts index 9b73c1d9..175ee264 100644 --- a/src/@fuse/services/config.service.ts +++ b/src/@fuse/services/config.service.ts @@ -8,7 +8,9 @@ import * as _ from 'lodash'; // Create the injection token for the custom settings export const FUSE_CONFIG = new InjectionToken('fuseCustomConfig'); -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class FuseConfigService { // Private diff --git a/src/@fuse/services/copier.service.ts b/src/@fuse/services/copier.service.ts index 1b431b0b..e3f8cc87 100644 --- a/src/@fuse/services/copier.service.ts +++ b/src/@fuse/services/copier.service.ts @@ -1,14 +1,15 @@ /** * This class is based on the code in the following projects: - * - * - https://github.com/zenorocha/select - * - https://github.com/zenorocha/clipboard.js/ + * https://github.com/zenorocha/select + * https://github.com/zenorocha/clipboard.js/ * * Both released under MIT license - © Zeno Rocha */ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class FuseCopierService { private textarea: HTMLTextAreaElement; diff --git a/src/@fuse/services/loading-bar.service.ts b/src/@fuse/services/loading-bar.service.ts index 26713a49..f9735e58 100644 --- a/src/@fuse/services/loading-bar.service.ts +++ b/src/@fuse/services/loading-bar.service.ts @@ -3,7 +3,9 @@ import { NavigationEnd, NavigationStart, Router } from '@angular/router'; import { BehaviorSubject, Observable } from 'rxjs'; import { filter } from 'rxjs/operators'; -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class FuseLoadingBarService { // Private diff --git a/src/@fuse/services/match-media.service.ts b/src/@fuse/services/match-media.service.ts index fdaa1f3c..e096900a 100644 --- a/src/@fuse/services/match-media.service.ts +++ b/src/@fuse/services/match-media.service.ts @@ -2,7 +2,9 @@ import { MediaChange, ObservableMedia } from '@angular/flex-layout'; import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class FuseMatchMediaService { activeMediaQuery: string; diff --git a/src/@fuse/services/splash-screen.service.ts b/src/@fuse/services/splash-screen.service.ts index 6ad009d9..0e328fbc 100644 --- a/src/@fuse/services/splash-screen.service.ts +++ b/src/@fuse/services/splash-screen.service.ts @@ -3,7 +3,9 @@ import { DOCUMENT } from '@angular/common'; import { animate, AnimationBuilder, AnimationPlayer, style } from '@angular/animations'; import { NavigationEnd, Router } from '@angular/router'; -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class FuseSplashScreenService { splashScreenEl: any; diff --git a/src/@fuse/services/translation-loader.service.ts b/src/@fuse/services/translation-loader.service.ts index a26d7027..abb4e2d1 100644 --- a/src/@fuse/services/translation-loader.service.ts +++ b/src/@fuse/services/translation-loader.service.ts @@ -7,7 +7,9 @@ export interface Locale data: Object; } -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class FuseTranslationLoaderService { /**