libs/playground-test-bbs/plugins/src/lib/state-update-plugin/state-update-plugin.ts
Methods |
registerActions |
registerActions()
|
Returns :
void
|
This is a more detailed description of this plugin.
import { PfeActionsService, PfeBusinessService } from '@allianz/ngx-pfe';
import { Injectable, inject } from '@angular/core';
@Injectable()
export class StateUpdatePlugin {
private readonly pfeActionService = inject(PfeActionsService);
private readonly pfeBusinessService = inject(PfeBusinessService);
private count = 0;
registerActions() {
this.pfeActionService.registerAction('PLAYGROUND_STATE_UPDATE', this.updateState.bind(this));
}
private updateState(): Promise<void> {
if (this.pfeBusinessService.getValueByExpression("$['bb-pgr-simple'].done")) {
this.pfeBusinessService.storeValueByExpression('$.validationErrorDataTest', null);
this.pfeBusinessService.storeValueByExpression('$.errorFromPlugin', null);
return Promise.resolve();
}
this.count++;
if (this.count < 2) {
return new Promise((resolve) => {
setTimeout(() => {
this.pfeBusinessService.storeValueByExpression(
'$.validationErrorDataTest',
'this is an error from the $.validationErrorDataTest'
);
this.pfeBusinessService.storeValueByExpression(
'$.errorFromPlugin',
'this is an error from the $.errorFromPlugin'
);
resolve();
}, 1000);
});
}
return new Promise((resolve) => {
resolve();
setTimeout(() => {
this.pfeBusinessService.storeValueByExpression('$.validationErrorDataTest', null);
this.pfeBusinessService.storeValueByExpression('$.errorFromPlugin', null);
resolve();
}, 1500);
});
}
}