I have an array of observables.
On my ngOnInit() method, I initialize my subscriptions.
this.lineOrdersSub[line.$key] = this.af.database.list(this.businessService.path + 'line_orders/' + line.$key)
.subscribe((lineOrders) => {
this.line_orders[line.$key] = lineOrders;
});
I also have a checkbox for each subscription. When the checkbox is ticked (default), the subscription is active (subscribing to new data).
When I uncheck a checkbox, I do this:
unCheckmethod() {
this.lineOrdersSub[line.$key].unsubscribe(); //Unsubscribe to my subscription
this.line_orders[line.$key] = null; // Remove the data I get after the subscription (See first code snippet)
}
My uncheck method works well, but after I'm trying to start the subscription again with:
checkMethod() {
this.lineOrdersSub[line.$key].subscribe();
}
I get:
this.lineOrdersSub[line.$key].subscribe is not a function
My question:
- How I can subscribe to a subscription after I
unsubscribe? If impossible, Can you think of any other way to do this?