From 24e80e4e7330fc96331c9ae16879913ac9a0adb9 Mon Sep 17 00:00:00 2001 From: tomastrajan Date: Wed, 7 Nov 2018 22:53:52 +0100 Subject: [PATCH] feat(ngrx): move tu .subscribe() less architecture, use | async pipe instead --- package.json | 6 +- src/app/app.component.ts | 2 - src/app/core/animations/route.animations.ts | 2 +- src/app/core/auth/auth.effects.spec.ts | 9 +- src/app/core/core.module.ts | 10 +- src/app/core/index.ts | 1 + .../examples/examples/examples.component.html | 7 + .../examples/examples/examples.component.ts | 68 +++----- .../form/components/form.component.html | 6 +- .../form/components/form.component.spec.ts | 3 +- .../form/components/form.component.ts | 54 +++--- src/app/examples/form/form.selectors.ts | 4 +- .../notifications.component.spec.ts | 5 +- .../components/notifications.component.ts | 9 +- .../stock-market-container.component.html | 86 +++++----- .../stock-market-container.component.scss | 2 +- ...market-container.component.scss-theme.scss | 2 +- .../stock-market-container.component.spec.ts | 2 +- .../stock-market-container.component.ts | 38 +---- .../stock-market/stock-market.effects.spec.ts | 2 +- .../components/todos-container.component.html | 105 ++++++------ .../todos-container.component.spec.ts | 2 +- .../components/todos-container.component.ts | 46 +----- src/app/examples/todos/todos.actions.spec.ts | 14 -- src/app/examples/todos/todos.actions.ts | 12 +- src/app/examples/todos/todos.effects.spec.ts | 22 ++- src/app/examples/todos/todos.effects.ts | 21 ++- .../settings-container.component.html | 156 +++++++++--------- .../settings-container.component.spec.ts | 17 +- .../settings-container.component.ts | 40 +---- src/app/settings/settings.actions.spec.ts | 28 ---- src/app/settings/settings.actions.ts | 12 +- src/app/settings/settings.effects.spec.ts | 18 +- src/app/settings/settings.effects.ts | 23 ++- src/app/settings/settings.selectors.ts | 5 + src/app/static/features/features.component.ts | 4 +- src/app/static/features/features.data.ts | 10 +- src/app/static/features/features.model.ts | 8 - 38 files changed, 374 insertions(+), 487 deletions(-) delete mode 100644 src/app/static/features/features.model.ts diff --git a/package.json b/package.json index 9868d9f75..48be7aac2 100755 --- a/package.json +++ b/package.json @@ -15,10 +15,10 @@ "clean": "rimraf ./dist/", "server": "node ./server.js", "prod": "npm run clean && npm run build:prod && npm run server", - "ci": "npm run clean && npm run prettier:ci && ng lint && ng test --configuration=test --browsers ChromeTravisCi --code-coverage && ng e2e && npm run cy:ci && npm run accessibility && npm run build:prod -- --deploy-url /angular-ngrx-material-starter/ --base-href /angular-ngrx-material-starter", + "ci": "npm run clean && npm run format:test && ng lint && ng test --configuration=test --browsers ChromeTravisCi --code-coverage && ng e2e && npm run cy:ci && npm run accessibility && npm run build:prod -- --deploy-url /angular-ngrx-material-starter/ --base-href /angular-ngrx-material-starter", "release": "standard-version && git push --follow-tags origin master", - "prettier": "prettier {src,e2e,cypress}/**/*.{ts,json,md,scss} --write", - "prettier:ci": "prettier {src,e2e,cypress}/**/*.{ts,json,md,scss} --list-different", + "format:write": "prettier {src,e2e,cypress}/**/*.{ts,json,md,scss} --write", + "format:test": "prettier {src,e2e,cypress}/**/*.{ts,json,md,scss} --list-different", "analyze": "npm run clean && npm run build:prod -- --stats-json && webpack-bundle-analyzer ./dist/stats.json", "contributors:add": "all-contributors add", "contributors:generate": "all-contributors generate && node .all-contributors-html.js", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 7748c8515..17065b8c4 100755 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -23,7 +23,6 @@ import { NIGHT_MODE_THEME, selectSettings, SettingsState, - ActionSettingsPersist, ActionSettingsChangeLanguage, ActionSettingsChangeAnimationsPageDisabled } from './settings'; @@ -102,7 +101,6 @@ export class AppComponent implements OnInit, OnDestroy { onLanguageSelect({ value: language }) { this.store.dispatch(new ActionSettingsChangeLanguage({ language })); - this.store.dispatch(new ActionSettingsPersist({ settings: this.settings })); } private subscribeToIsAuthenticated() { diff --git a/src/app/core/animations/route.animations.ts b/src/app/core/animations/route.animations.ts index 38b4135a9..d08a3d329 100755 --- a/src/app/core/animations/route.animations.ts +++ b/src/app/core/animations/route.animations.ts @@ -50,7 +50,7 @@ const STEPS_ALL: any[] = [ query( ':enter .' + ROUTE_ANIMATIONS_ELEMENTS, stagger(75, [ - style({ transform: 'translateY(15%)', opacity: 0 }), + style({ transform: 'translateY(10%)', opacity: 0 }), animate( '0.5s ease-in-out', style({ transform: 'translateY(0%)', opacity: 1 }) diff --git a/src/app/core/auth/auth.effects.spec.ts b/src/app/core/auth/auth.effects.spec.ts index 3d3e7dafd..be7654ff8 100644 --- a/src/app/core/auth/auth.effects.spec.ts +++ b/src/app/core/auth/auth.effects.spec.ts @@ -1,9 +1,14 @@ import { Router } from '@angular/router'; -import { LocalStorageService } from '@app/core'; -import { ActionAuthLogin, ActionAuthLogout } from '@app/core/auth/auth.actions'; import { Actions, getEffectsMetadata } from '@ngrx/effects'; import { cold } from 'jasmine-marbles'; import { EMPTY } from 'rxjs'; + +import { + LocalStorageService, + ActionAuthLogin, + ActionAuthLogout +} from '@app/core'; + import { AuthEffects, AUTH_KEY } from './auth.effects'; describe('AuthEffects', () => { diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index 3c08581cf..85180a10f 100755 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -6,9 +6,14 @@ import { EffectsModule } from '@ngrx/effects'; import { StoreDevtoolsModule } from '@ngrx/store-devtools'; import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; +import { + StoreRouterConnectingModule, + RouterStateSerializer +} from '@ngrx/router-store'; import { environment } from '@env/environment'; +import { httpInterceptorProviders } from './http-interceptors'; import { LocalStorageService } from './local-storage/local-storage.service'; import { AuthEffects } from './auth/auth.effects'; import { AuthGuardService } from './auth/auth-guard.service'; @@ -16,11 +21,6 @@ import { AnimationsService } from './animations/animations.service'; import { TitleService } from './title/title.service'; import { reducers, metaReducers } from './core.state'; import { AppErrorHandler } from './error-handler/app-error-handler.service'; -import { httpInterceptorProviders } from '@app/core/http-interceptors'; -import { - StoreRouterConnectingModule, - RouterStateSerializer -} from '@ngrx/router-store'; import { CustomSerializer } from './router/custom-serializer'; import { NotificationService } from './notifications/notification.service'; diff --git a/src/app/core/index.ts b/src/app/core/index.ts index 1834fab0a..651e9ab43 100755 --- a/src/app/core/index.ts +++ b/src/app/core/index.ts @@ -5,6 +5,7 @@ export * from './auth/auth.reducer'; export * from './auth/auth.actions'; export * from './auth/auth.selectors'; export * from './auth/auth-guard.service'; +export * from './notifications/notification.service'; export * from './router/router.state'; export * from './title/title.service'; export * from './core.state'; diff --git a/src/app/examples/examples/examples.component.html b/src/app/examples/examples/examples.component.html index 9f6805f2d..4e52e3171 100755 --- a/src/app/examples/examples/examples.component.html +++ b/src/app/examples/examples/examples.component.html @@ -1,3 +1,10 @@ + + {{updateLanguage(language)}} + + + {{updateTitle(snapshot)}} + +