File
Public
resetState
|
Default value : () => {...}
|
|
import { Injectable } from '@angular/core';
import { JsonPathExpression } from '../../models/jsonpath-expression-type.model';
import { PfeStateService } from './../../services/pfe-state-service/state.service';
import { PfeResetStateActionConfig } from './reset-state.model';
@Injectable()
export class PfeResetStateService {
constructor(protected pfeStateService: PfeStateService) {}
public resetState = async (actionConfig: PfeResetStateActionConfig): Promise<void> => {
const stateToKeepMap = new Map<JsonPathExpression, unknown>();
actionConfig.excludeFromResetExpressions?.forEach((exceptionExpression) => {
const stateValue = this.pfeStateService.getStateValueByExpression(exceptionExpression);
stateToKeepMap.set(exceptionExpression, stateValue);
});
await this.pfeStateService.resetState();
for (const [key, value] of stateToKeepMap.entries()) {
this.pfeStateService.storeValueByExpression(key, value);
}
return;
};
}