Youen Toupin
3 years ago
4 changed files with 46 additions and 8 deletions
@ -0,0 +1,21 @@
|
||||
export class Pipe<ValueType> |
||||
{ |
||||
private changeCallbacks: ((newValue: ValueType) => void)[] = [];
|
||||
|
||||
constructor(private value: ValueType) { |
||||
} |
||||
|
||||
get() { return this.value; } |
||||
|
||||
set(value: ValueType) |
||||
{ |
||||
this.value = value; |
||||
for(let callback of this.changeCallbacks) { |
||||
callback(value); |
||||
} |
||||
} |
||||
|
||||
onChange(callback: (newValue: ValueType) => void) { |
||||
this.changeCallbacks.push(callback); |
||||
} |
||||
} |
Loading…
Reference in new issue