How to use the @ngxs/store.ofAction function in @ngxs/store

To help you get started, we’ve selected a few @ngxs/store 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 mflorence99 / el-aws / renderer / app / pages / s3 / ctrl.ts View on Github external
private handleActions(): void {
    // listen for open prefs
    this.subToShowPagePrefs = this.actions$.pipe(ofAction(ShowPagePrefs))
      .subscribe(() => this.openView.emit());
    // clean up on a reset
    this.subToReset = this.actions$.pipe(ofAction(Reset))
      .subscribe(() => this.store.dispatch(new ClearPaths()));
    // cancel long-running operation
    this.subToCancel = this.actions$.pipe(ofAction(Canceled))
      .subscribe(() => {
        this.zone.run(() => {
          this.store.dispatch(new Progress({ state: 'completed' }));
          this.s3Svc.cancelUpload();
        });
      });
  }
github mflorence99 / el-aws / renderer / app / pages / s3 / ctrl.ts View on Github external
private handleActions(): void {
    // listen for open prefs
    this.subToShowPagePrefs = this.actions$.pipe(ofAction(ShowPagePrefs))
      .subscribe(() => this.openView.emit());
    // clean up on a reset
    this.subToReset = this.actions$.pipe(ofAction(Reset))
      .subscribe(() => this.store.dispatch(new ClearPaths()));
    // cancel long-running operation
    this.subToCancel = this.actions$.pipe(ofAction(Canceled))
      .subscribe(() => {
        this.zone.run(() => {
          this.store.dispatch(new Progress({ state: 'completed' }));
          this.s3Svc.cancelUpload();
        });
      });
  }
github mflorence99 / el-aws / renderer / app / pages / s3 / ctrl.ts View on Github external
private handleActions(): void {
    // listen for open prefs
    this.subToShowPagePrefs = this.actions$.pipe(ofAction(ShowPagePrefs))
      .subscribe(() => this.openView.emit());
    // clean up on a reset
    this.subToReset = this.actions$.pipe(ofAction(Reset))
      .subscribe(() => this.store.dispatch(new ClearPaths()));
    // cancel long-running operation
    this.subToCancel = this.actions$.pipe(ofAction(Canceled))
      .subscribe(() => {
        this.zone.run(() => {
          this.store.dispatch(new Progress({ state: 'completed' }));
          this.s3Svc.cancelUpload();
        });
      });
  }
github mflorence99 / el-aws / renderer / app / pages / ddb / ctrl.ts View on Github external
private handleActions(): void {
    // listen for open prefs
    this.subToShowPagePrefs = this.actions$.pipe(ofAction(ShowPagePrefs))
      .subscribe(() => this.openView.emit());
  }
github mflorence99 / el-aws / renderer / app / pages / root / ctrl.ts View on Github external
private handleActions(): void {
    // handle general Cancel in case of long running main process action 
    this.subToCancel = this.actions$.pipe(ofAction(Canceled))
      .subscribe(() => this.electron.ipcRenderer.send('cancel'));
  }
github mflorence99 / el-file / renderer / app / state / clipboard.ts View on Github external
ngxsOnInit({ dispatch }: StateContext) {
    this.actions$
      .pipe(ofAction(DirLoaded, DirUnloaded))
      .subscribe(() => dispatch(new ValidateClipboard));
  }
github mflorence99 / el-file / renderer / app / state / layout.ts View on Github external
private handleDirUnloaded({ dispatch, getState }: StateContext): void {
    this.actions$
      .pipe(ofAction(DirUnloaded))
      .subscribe(({ path }) => {
        const layout = getState();
        LayoutState.visitTabs(layout, (tab: Tab) => {
          const ix = tab.paths.indexOf(path);
          if (ix !== -1)
            dispatch(new RemovePathFromTab({ path, tab }));
        });
      });
  }