Reputation: 7752
I'm creating a form where the user will be able to add multiple rows with knockout.js, each row will have a 5 inputs
and the user could potentially add hundreds of rows.
I want to use observable array and make it's properties also observable, for each input.
So it would be likely for some users there could be approx 5000 observable properties on the page.
Is there any performance issues which could arise from such an approach? Could is slow down the browser? And if there is, are there any methods to protect against it.
Upvotes: 0
Views: 130
Reputation: 1707
We're using controls with observables en observableArrays that hold 20k+ records clientside and we're now hitting a bit of a javascript/knockout wall. with 5k it still went pretty smooth but it also strongly depends on the client's browser/hardware.
1 major issue while updating all items in an obs. array is that if you'll iterate the change it would hang the page until the end of the iteration. You could use the apply method to get around that if logic allows that. Function.prototype.apply()
I'd say if you're 100% sure it won't grow over 5k, go for it, it'll work. But honestly nowadays you'd probably be better of leaving most of the data on the server and only retrieve what you need at that point.
Upvotes: 1