rxjs/Subscription undefined value of another subscription -


i need use value of subscription subscription. here code. product value undefined, best method access value?

code:

@component({     selector: 'product-page',     templateurl: 'product-page.html' }) export class productpage {     private product: product;     this.store.select('products').subscribe(({         product     }) => {         if (product) {             this.product = product;         }     });     this.store.select('plc').subscribe((value: any) = > {         console.log(this.product); // undefined     }) } 

you can combine 2 selections using combinelatest operator:

import 'rxjs/add/operator/combinelatest'; // ...  this.store   .select('products')   .combinelatest(this.store.select('plc'))   .subscribe(([products, plc]) => {     // ...   }); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -