I have a computed array like this,
self.weapons = ko.observableArray(
[]
);
self.wings = ko.observableArray(
[]
);
self.itemList = ko.computed( function()
{
return self.weapons().concat(self.wings());
}
},
this );
i would like to sort this array.
i can sort ko.observableArray with no problem.
issue here is i think, ko.computed is computes back again after the sorting is done.
also: is there a better way concatenating multiple observableArrays together?
Thank you.
Just sort the concatenated array.
It will have to be resorted every time either array changes but there’s not much you can do about that.
If you are going to make many changes in succession, consider using the
rateLimitextender (orthrottleprior to knockout 3.1.x) on your computed observable. This will limit the amount of times notifications are sent out by the observable by collapsing all notifications made within a certain time period.