How to use @ngxs/router-plugin - 10 common examples

To help you get started, we’ve selected a few @ngxs/router-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xlayers / xlayers / src / app / upload / upload.component.ts View on Github external
async onFileSelected(file: File) {
    try {
      const data = await this.sketchService.loadSketchFile(file);
      this.isDragging$.next(false);
      // Note: these actions need to be run in sequence!
      this.store.dispatch([
        new ResetUiSettings(),
        new CurrentData(data),
        new Navigate(['/editor/preview'])
      ]);
    } catch (error) {
      this.store.dispatch(new InformUser(error, ErrorType.Runtime));
      throw error;
    }
  }
github abpframework / abp / npm / ng-packs / dist / theme-basic / esm5 / lib / components / application-layout / application-layout.component.js View on Github external
function () {
        this.oauthService.logOut();
        this.store.dispatch(new Navigate(['/'], null, {
            state: { redirectUrl: this.store.selectSnapshot(RouterState).state.url },
        }));
        this.store.dispatch(new GetAppConfiguration());
    };
    // required for dynamic component
github xlayers / xlayers / src / app / app.module.ts View on Github external
{ name: 'vue', func: xml }
  ];
}

const StoreDebugModule = [
  NgxsModule.forRoot([UiState, CodeGenState], {
    /**
     * WARNING: dont enbale the `developmentmode` config until it's been fixed!
     * ENABLING THIS, WILL THROW: TypeError: Cannot assign to read only property 'microTask' of object '[object Object]'
     * See similar issue in NgRx: https://github.com/brandonroberts/ngrx-store-freeze/issues/17
     */
    // developmentMode: !environment.production
  }),
  NgxsLoggerPluginModule.forRoot({ disabled: environment.production }),
  NgxsReduxDevtoolsPluginModule.forRoot({ disabled: environment.production }),
  NgxsRouterPluginModule.forRoot()
];

// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient) {
  return new TranslateHttpLoader(http);
}


@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    HttpClientModule,
    BrowserAnimationsModule,
    StoreDebugModule,
    CoreModule,
github T-Systems-MMS / phonebook / Phonebook.Frontend / src / app / app.module.ts View on Github external
DialogsModule,
    ProfilePictureModule,
    SettingsModule,
    UserModule,
    FeatureFlagModule.forRoot(),
    NotImplementedModule,
    FeedbackDrawerModule,
    MatBadgeModule,
    NgxsModule.forRoot([AppState, BookmarksState, LastPersonsState, CommonPersonsState, SearchState, TableState], {
      // TODO: Fix https://github.com/T-Systems-MMS/phonebook/issues/95 first.
      // developmentMode: !environment.production
    }),
    NgxsStoragePluginModule.forRoot({
      key: ['appstate', 'bookmarks', 'commonpersons', 'lastpersons', 'tablestate']
    }),
    NgxsRouterPluginModule.forRoot(),
    NgxsLoggerPluginModule.forRoot({ disabled: environment.production }),
    NgxsReduxDevtoolsPluginModule.forRoot({ disabled: environment.production }),
    AddFilterModule,
    TableModule,
    ApiModule,
    // Has to be included here because of https://stackoverflow.com/a/41519512/9277073
    FeedbackDrawerModule,
    DragDropModule,
    ApiModule,
    IeWarningModule,
    PlatformModule,
    // Pages
    UserPagesModule
  ],
  providers: [
    {
github ForetagInc / fullstack-ts-boilerplate / libs / core / src / lib / core.module.ts View on Github external
@NgModule({
  providers: [
    CoreService,
  ],
  exports: [
    ClarityModule,
    ClrFormsNextModule,
  ],
  imports: [
    CommonModule,
    HttpClientModule,
    // NgxPageScrollModule,
    NgxsModule.forRoot([]),
    NgxsFormPluginModule.forRoot(),
    NgxsRouterPluginModule.forRoot(),
    ClarityModule,
    ClrFormsNextModule,
    GraphqlModule,
    AuthModule,
    I18nModule,
    NgxsReduxDevtoolsPluginModule.forRoot({
      disabled: environment.production,
    }),
    NgxsStoragePluginModule.forRoot({
      key: 'auth.token',
    }),
  ]
})
export class CoreModule {
  constructor(
    @Optional()
github T-Systems-MMS / phonebook / Phonebook.Frontend / src / app / shared / states / Search.state.ts View on Github external
private updateURL(ctx: StateContext, action: UpdateUrl) {
    const update = action.update;
    const params: { [key: string]: string | null } = {};
    const routeState = this.store.selectSnapshot(RouterState.state);
    // For Unit Testing
    // Maybe this is a solution to not modify production code: https://github.com/ngxs/store/blob/master/packages/router-plugin/tests/router.plugin.spec.ts
    if (routeState == undefined) {
      return;
    }
    const routeSnapshot: ActivatedRouteSnapshot = routeState.root;
    if (update.searchFilter != null) {
      update.searchFilter.forEach(filter => {
        params[filter.filterColumn.id] = filter.filterValue;
      });
      // Remove Query Params that are not used anymore by setting them 'null' explicitly
      if (routeSnapshot.firstChild != null && routeSnapshot.firstChild.firstChild != null) {
        const queryParams = routeSnapshot.firstChild.firstChild.queryParams;
        Object.keys(queryParams).forEach(queryParamKey => {
          if (params[queryParamKey] == null) {
            if (!isSortKey(queryParamKey)) {
github ngxs / ngxs-examples / timekeeper / src / app / auth / auth.state.ts View on Github external
onLoginRedirect(ctx: StateContext) {
    console.log('onLoginRedirect, navigating to /auth/login');
    ctx.dispatch(new Navigate(['/auth/login']));
  }
github xmlking / ngx-starter-kit / libs / admin / src / lib / containers / admin-layout / admin-layout.component.ts View on Github external
ngOnInit() {
    this.crumbs$ = this.store
      .select(RouterState.state)
      .pipe(map(state => Array.from(state.breadcrumbs, ([key, value]) => ({ name: key, link: '/' + value }))));

    this.depth$ = this.store.select(RouterState.state).pipe(map(state => state.data.depth));
  }
github xmlking / ngx-starter-kit / libs / admin / src / lib / containers / admin-layout / admin-layout.component.ts View on Github external
ngOnInit() {
    this.crumbs$ = this.store
      .select(RouterState.state)
      .pipe(map(state => Array.from(state.breadcrumbs, ([key, value]) => ({ name: key, link: '/' + value }))));

    this.depth$ = this.store.select(RouterState.state).pipe(map(state => state.data.depth));
  }
github xmlking / ngx-starter-kit / libs / dashboard / src / lib / containers / dashboard-layout / dashboard-layout.component.ts View on Github external
ngOnInit() {
    this.crumbs$ = this.store
      .select(RouterState.state)
      .pipe(map(state => Array.from(state.breadcrumbs, ([key, value]) => ({ name: key, link: '/' + value }))));

    this.depth$ = this.store.select(RouterState.state).pipe(map(state => state.data.depth));

    this.mediaObserver
      .asObservable()
      .pipe(
        filter((changes: MediaChange[]) => changes.length > 0),
        map((changes: MediaChange[]) => changes[0]),
      )
      .subscribe((change: MediaChange) => {
        const isMobile = change.mqAlias === 'xs' || change.mqAlias === 'sm';

        this.isMobile = isMobile;
        this.sidenavMode = isMobile ? 'over' : 'side';
        this.sidenavOpen = !isMobile;
      });

    this.router.events.pipe().subscribe(event => {

@ngxs/router-plugin

router plugin for @ngxs/store

MIT
Latest version published 5 months ago

Package Health Score

88 / 100
Full package analysis