What I’m trying to do is the following:
var queueManagerClass = function() {
this.queue = ko.observableArray();
this.queue.subscribe( function(theChangedQueue) {
// Do some nice things..
// Nice things are over, remove the last item from the queue..
this.queue.remove(theChangedQueue.pop());
}.bind(this));
};
Except 2 problems occur: when I call this.queue.remove(item); I’ll end up in an infinite loop.. The subscribe function will call it self over and over again..
I know there is an option to ‘unbind’ the subscribe function temporally but I can’t risk the fact that I miss a queueItem that’s inserted in the mean time of unbinding and binding again.
I hope you’ll understand my (not so great..) english.
Thanks for your time!
One way to work around this is to make it detectable that you are in the process of removing the item and specifically ignore the event when that happens. This can be done by using a local to store the “isRemoving” state. For example