javascript - .asObservable dont want to work with Observable.forkJoin -


i have service:

export class configservice {   private _config: behaviorsubject<object> = new behaviorsubject(null);   public config: observable<object> = this._config.asobservable();    constructor(private api: apiservice) {     this.loadconfigs();   }    loadconfigs() {    this.api.get('/configs').subscribe( res => this._config.next(res) );   } } 

trying call component:

... observable.forkjoin([someservice.config])   .subscribe( res => console.log(res) ) //not working   someservice.config.subscribe( res => console.log(res) ) // working ... 

how can use observable.forkjoin observable variable config?

i need store configs in service , wait unlit them , others request not finished stop loader.

since you're using behaviorsubject should know can call next() , complete() manually.

the forkjoin() operator emits when of source observables have emitted @ least 1 values and completed. since you're using subject , asobservable method source observable never completes , forkjoin operator never emits anything.

btw, doesn't make sense use forkjoin 1 source observable. maybe have @ zip() or combinelatest() operators similar , maybe it's need.

two similar question:


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -