tuain-ng-forms-lib 15.0.31 → 15.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2726,21 +2726,23 @@ class LibEventManagerService {
2726
2726
  eventSet.forEach((event) => { this.addEventName(event); });
2727
2727
  }
2728
2728
  addEventName(event, rebuild = false) {
2729
- let name;
2730
- let windowTime;
2731
- let timestampProvider;
2732
- if (typeof event === 'string') {
2733
- name = event;
2734
- }
2735
- else {
2736
- name = event.name;
2737
- windowTime = event.windowTime;
2738
- timestampProvider = event.timestampProvider;
2739
- }
2740
- if (rebuild || !this.eventSubjects[name]) {
2741
- const newEventSubject = new ReplaySubject(1, windowTime, timestampProvider);
2742
- this.eventSubjects[name] = newEventSubject;
2743
- this.eventSubjectParams[name] = { name, windowTime, timestampProvider };
2729
+ const eventObject = (typeof event === 'string') ? { name: event } : event;
2730
+ const { name, type, initialValue, windowTime, timestampProvider } = eventObject;
2731
+ const currentSubject = this.eventSubjects[name];
2732
+ if (rebuild || !currentSubject) {
2733
+ if (type === 'behaviour') {
2734
+ const newEventSubject = new BehaviorSubject(initialValue);
2735
+ this.eventSubjects[name] = newEventSubject;
2736
+ }
2737
+ else if (type === 'subject') {
2738
+ const newEventSubject = new Subject();
2739
+ this.eventSubjects[name] = newEventSubject;
2740
+ }
2741
+ else {
2742
+ const newEventSubject = new ReplaySubject(initialValue, windowTime, timestampProvider);
2743
+ this.eventSubjects[name] = newEventSubject;
2744
+ }
2745
+ this.eventSubjectParams[name] = { name: name, windowTime, timestampProvider };
2744
2746
  }
2745
2747
  }
2746
2748
  resetSubject(eventClassName) {
@@ -3028,7 +3030,7 @@ class BasicFormComponent extends FormStructureAndData {
3028
3030
  return stateChanged;
3029
3031
  }
3030
3032
  checkErrorRecordReceived(recordResponse) {
3031
- const { error } = recordResponse;
3033
+ const { error } = recordResponse ?? {};
3032
3034
  if (!error) {
3033
3035
  return false;
3034
3036
  }