@coffeeee wrote:
Hey,
I am using a sectionSelect to select particular categories to subscribe to. Another view would only list items of the selected categories.
So far, I simply determine a subscription based on a “subscribed = 1” element for a particular category
0: {id: 0, cat: "A", subscribed: 0} 1: {id: 1, cat: "B", subscribed: 1} 2: {id: 4, cat: "C", subscribed: 0}
So now my ionChange function returns a list of objects the user wants to update his subscription to. Like the list above. So now I would first have to remove all other active subscriptions by setting subscribed to 0 for all categories, and in another go update all subscriptions to 1 for the selection. I do this in the following manner:
updateClick($event){ this.myItemProvider.clearSubscriptions(); let i = 0; $event.forEach((cat) => { this.myItemProvider.setSubscription($event[i].id); i++; }); }
I wondered if there is a more beautiful approach for that, and if I would run into any issues with that.
Furthermore, is there a more modern approach to iterate through the objects other than foreach with an manually incrementing i++?
Thanks in advance!
Posts: 4
Participants: 2