How to use the @ngxs/store.getActionTypeFromInstance 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 ngxs / store / packages / devtools-plugin / src / devtools.plugin.ts View on Github external
private sendToDevTools(state: any, action: any, newState: any) {
    const type = getActionTypeFromInstance(action);
    // if init action, send initial state to dev tools
    const isInitAction = type === '@@INIT';
    if (isInitAction) {
      this.devtoolsExtension!.init(state);
    } else {
      this.devtoolsExtension!.send({ ...action, type }, newState);
    }
  }
github xmlking / ngx-starter-kit / libs / socketio-plugin / src / lib / websocket-handler.ts View on Github external
actions.pipe(ofActionDispatched(SendWebSocketAction)).subscribe(({ payload }) => {
      const type = getActionTypeFromInstance(payload);
      socket.send({ ...payload, type });
    });
    actions.pipe(ofActionDispatched(AuthenticateWebSocket)).subscribe(event => socket.auth({ sumo: 1 }));
github ngxs / store / packages / logger-plugin / src / action-logger.ts View on Github external
private getActionLogHeader() {
    const actionName = getActionTypeFromInstance(this.action);
    const formattedTime = formatTime(this.startedTime);
    const message = `action ${actionName} (started @ ${formattedTime})`;
    return message;
  }
github ngxs / store / packages / form-plugin / src / form.plugin.ts View on Github external
handle(state: any, event: any, next: NgxsNextPluginFn) {
    const type = getActionTypeFromInstance(event);

    let nextState = state;

    if (type === UpdateFormValue.type || type === UpdateForm.type) {
      const { value } = event.payload;
      const payloadValue = Array.isArray(value) ? value.slice() : { ...value };
      const path = this.joinPathWithPropertyPath(event);
      nextState = setValue(nextState, path, payloadValue);
    }

    if (type === UpdateFormStatus.type || type === UpdateForm.type) {
      nextState = setValue(nextState, `${event.payload.path}.status`, event.payload.status);
    }

    if (type === UpdateFormErrors.type || type === UpdateForm.type) {
      nextState = setValue(nextState, `${event.payload.path}.errors`, {