blob: 3201e0b68a06fd707c1f7dcff2725df1fd3cb450 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import { Subject } from 'rxjs/Subject';
import { IValidatableComponent } from './validatable.interface';
export abstract class ValidatableComponent implements IValidatableComponent {
// Each ValidatableComponent should handle the style in case of error, according to this boolean
public valid: boolean;
public dirty: boolean;
// Each ValidatableComponent will notify when the value is changed.
public notifier: Subject<string>;
constructor() {
this.notifier = new Subject();
this.dirty = false;
}
public abstract getValue(): any;
// Each ValidatableComponent should call the valueChanged on value changed function.
protected valueChanged = (value: any): void => {
this.dirty = true;
this.notifier.next(value);
}
}
|