what's the correct RXJS approach to passing numbers within an Angular 5 app (no API)?
I've successfully passed a boolean with Subject :
service :
import {Injectable} from '@angular/core';
import {Subject} from 'rxjs/Subject';
@Injectable()
export class IsOpened {
data = new Subject();
constructor() {}
insertData(data){
this.data.next(data);
}
}
emitter :
toggle(){
this.opening = !this.opening;
this._isOpened.insertData(this.opening);
}
listener :
ngAfterViewInit() {
this._isOpened.data.subscribe((value) => {
if(value) this.opened = true;
else this.opened = false;
}});
}
I sorta cheat in the listener because I don't store the received value but rather assess that and re-create the boolean.
works for me and fits in very few lines.
I can't do the same with numbers.
how would I do it with numbers? with arrays?
Google and the many RXJS info sources yielded nothing.