Change Selectable<T> to store selected as a behaviour subject
Signed-off-by: trivernis <trivernis@protonmail.com>pull/3/head
parent
d3700932db
commit
4568afe6f9
@ -1,12 +1,18 @@
|
||||
import {BehaviorSubject} from "rxjs";
|
||||
|
||||
export class Selectable<T> {
|
||||
constructor(public data: T, public selected: boolean) {
|
||||
|
||||
public selected: BehaviorSubject<boolean>;
|
||||
|
||||
constructor(public data: T, selected: boolean) {
|
||||
this.selected = new BehaviorSubject<boolean>(selected);
|
||||
}
|
||||
|
||||
public select() {
|
||||
this.selected = true;
|
||||
this.selected.next(true);
|
||||
}
|
||||
|
||||
public unselect() {
|
||||
this.selected = false;
|
||||
this.selected.next(false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue