Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
}
actions.pipe(ofActionDispatched(SendWebSocketAction)).subscribe(({ payload }) => {
const type = getActionTypeFromInstance(payload);
socket.send({ ...payload, type });
});
actions.pipe(ofActionDispatched(AuthenticateWebSocket)).subscribe(event => socket.auth({ sumo: 1 }));
private getActionLogHeader() {
const actionName = getActionTypeFromInstance(this.action);
const formattedTime = formatTime(this.startedTime);
const message = `action ${actionName} (started @ ${formattedTime})`;
return message;
}
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`, {