How to use the @ngxs/store.ofActionDispatched 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 xmlking / ngx-starter-kit / apps / default / src / app / core / state / eventbus.ts View on Github external
constructor(private actions$: Actions) {
    this.actions$.pipe(ofActionDispatched(Login)).subscribe(action => console.log('Login.......Action Dispatched'));
    this.actions$.pipe(ofActionSuccessful(Login)).subscribe(action => console.log('Login........Action Successful'));
    this.actions$.pipe(ofActionErrored(Login)).subscribe(action => console.log('Login........Action Errored'));
  }
}
github mehmet-erim / ngx-performance-ui / src / app / @ui / directives / popover.directive.ts View on Github external
subscribeTo() {
    this.store.dispatch(new EventListenerAdd('resize'));

    this.resize$
      .pipe(
        filter(event => !!event),
        takeUntilNotNull(this.destroy$),
      )
      .subscribe(_ => this.hide());

    this.actions
      .pipe(
        ofActionDispatched(EventListenerScrollVertical),
        takeUntilNotNull(this.destroy$),
      )
      .subscribe(_ => this.hide());
  }
}
github ngxs / store / packages / websocket-plugin / src / websocket-handler.ts View on Github external
private setupActionsListeners(): void {
    this.actions$.pipe(ofActionDispatched(ConnectWebSocket)).subscribe(({ payload }) => {
      this.connect(payload);
    });

    this.actions$.pipe(ofActionDispatched(DisconnectWebSocket)).subscribe(() => {
      this.disconnect();
    });

    this.actions$.pipe(ofActionDispatched(SendWebSocketMessage)).subscribe(({ payload }) => {
      this.send(payload);
    });
  }
github ngxs / ngxs-examples / projects / wiki-search / src / app / wiki-article / content-component / content.component.ts View on Github external
private subscribeToActionDispatched(): void {
    this.actions$
      .pipe(
        ofActionDispatched(LoadContent),
        takeUntil(this.unsubscriber$)
      )
      .subscribe(() => {
        this.inProgress = true;
        this.errorString = null;
      });
  }
github openradiation / openradiation-mobile / src / app / states / devices / ble / ble-devices.service.ts View on Github external
constructor(
    private ble: BLE,
    private platform: Platform,
    private actions$: Actions,
    private store: Store,
    private diagnostic: Diagnostic,
    private alertService: AlertService,
    private translateService: TranslateService,
    private devicesService: DevicesService
  ) {
    this.actions$.pipe(ofActionDispatched(StartDiscoverBLEDevices)).subscribe(() => {
      if (this.currentAlert) {
        this.currentAlert.dismiss();
        this.currentAlert = undefined;
      }
    });
  }
github xmlking / ngx-starter-kit / libs / socketio-plugin / src / lib / websocket-handler.ts View on Github external
constructor(
    store: Store,
    actions: Actions,
    socket: WebSocketSubject,
    @Inject(NGXS_WEBSOCKET_OPTIONS) config: NgxsWebsocketPluginOptions,
  ) {
    actions.pipe(ofActionDispatched(ConnectWebSocket)).subscribe(event => socket.connect(event.payload));
    actions.pipe(ofActionDispatched(DisconnectWebSocket)).subscribe(event => socket.disconnect());
    actions.pipe(ofActionDispatched(SendWebSocketAction)).subscribe(({ payload }) => {
      const type = getActionTypeFromInstance(payload);
      socket.send({ ...payload, type });
    });
    actions.pipe(ofActionDispatched(AuthenticateWebSocket)).subscribe(event => socket.auth({ sumo: 1 }));
    socket.connectionStatus.pipe(distinctUntilChanged()).subscribe(status => {
      if (status) {
        store.dispatch(new WebSocketConnected({ socketId: socket.id }));
      } else {
        store.dispatch(new WebSocketDisconnected());
      }
    });
    socket.subscribe(
      msg => {
        const type = getValue(msg, config.typeKey);
        if (!type) {
          throw new Error(`Type ${type} not found on message`);
github xmlking / ngx-starter-kit / libs / chat-box / src / lib / state / chat-box.store.ts View on Github external
constructor(
    private nlp: NlpService,
    private stt: SpeechToTextService,
    private tts: TextToSpeechService,
    private chat: ChatService,
    private store: Store,
    private actions$: Actions,
  ) {
    this.actions$.pipe(ofActionDispatched(AddMessage)).subscribe((action: AddMessage) => {
      switch (action.payload.message.to.type) {
        case SubjectType.BOT:
          return this.nlp.process(action.payload.message.content).then(speech => {
            store.dispatch(
              new AddMessage({
                conversationId: action.payload.conversationId,
                message: ChatMessage.fromBotMessage(speech),
              }),
            );
            if (action.payload.message.mode === ModeType.SPEAK) {
              this.tts.synthesisVoice(speech, this.store.selectSnapshot(ChatBoxState.getVoicePreference));
            }
          });
        case SubjectType.USER:
        case SubjectType.ADMIN:
        case SubjectType.GROUP:
github mehmet-erim / ngx-performance-ui / src / app / @ui / directives / tooltip.directive.ts View on Github external
subscribeTo() {
    this.store.dispatch(new EventListenerAdd('resize'));

    this.resize$
      .pipe(
        filter(event => !!event),
        takeUntilNotNull(this.destroy$),
      )
      .subscribe(_ => this.hide());

    this.actions
      .pipe(
        ofActionDispatched(EventListenerScrollVertical),
        takeUntilNotNull(this.destroy$),
      )
      .subscribe(_ => this.hide());
  }
}
github ngxs / store / packages / websocket-plugin / src / websocket-handler.ts View on Github external
private setupActionsListeners(): void {
    this.actions$.pipe(ofActionDispatched(ConnectWebSocket)).subscribe(({ payload }) => {
      this.connect(payload);
    });

    this.actions$.pipe(ofActionDispatched(DisconnectWebSocket)).subscribe(() => {
      this.disconnect();
    });

    this.actions$.pipe(ofActionDispatched(SendWebSocketMessage)).subscribe(({ payload }) => {
      this.send(payload);
    });
  }