SUPPORT-9194: replace subscription with listener
This commit is contained in:
parent
db71ddab3a
commit
9e5916ca6b
1 changed files with 14 additions and 8 deletions
|
|
@ -1,9 +1,7 @@
|
|||
import {AnalyticalScope, Behavior, NotNull, ObjectRef, Text} from "@webbpm/base-package";
|
||||
import {Subscription} from "rxjs";
|
||||
import {OnDestroy} from "@angular/core";
|
||||
|
||||
@AnalyticalScope(Text)
|
||||
export class DigitDependentValue extends Behavior implements OnDestroy {
|
||||
export class DigitDependentValue extends Behavior {
|
||||
|
||||
@ObjectRef()
|
||||
@NotNull()
|
||||
|
|
@ -17,17 +15,19 @@ export class DigitDependentValue extends Behavior implements OnDestroy {
|
|||
public otherDigitValue: string;
|
||||
|
||||
private text: Text;
|
||||
private subscription: Subscription;
|
||||
private parentValueChangeListener: Function;
|
||||
private excludedNumbers: number[] = [11, 12, 13, 14];
|
||||
|
||||
initialize() {
|
||||
super.initialize();
|
||||
this.text = this.getScript(Text);
|
||||
this.subscription = this.parent.valueChangeEvent.subscribe(value => {
|
||||
this.parentValueChangeListener = () => {
|
||||
let value = this.parent.getValue();
|
||||
|
||||
if (value) {
|
||||
this.text.setValue(this.getValueDependOn(value));
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
private getValueDependOn(parentValue: string) {
|
||||
|
|
@ -43,7 +43,13 @@ export class DigitDependentValue extends Behavior implements OnDestroy {
|
|||
: this.otherDigitValue;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscription.unsubscribe();
|
||||
bindEvents() {
|
||||
super.bindEvents();
|
||||
this.parent.addChangeListener(this.parentValueChangeListener);
|
||||
}
|
||||
|
||||
unbindEvents() {
|
||||
super.unbindEvents();
|
||||
this.parent.removeChangeListener(this.parentValueChangeListener);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue