0

I'm in trouble. I have a large view model with a huge amount of subscribers to my observableArrays. When the observables change, I want to refresh the UI in between each notification to the subscribers so that the UI is still responsible while knockout is still computing the subscribers.

Is there any way to accomplish this?

Thank you!

1 Answer 1

2

To make UI more responsive use the "throttle" extender. That way multiple changes are re-evaluated as a single UI change.

For UI not to freeze, you would need to interrupt JavaScript process. So that UI can be updated. The way to do that, in your subscribers instead of doing processing immediately delay it:

model.value.subscribe(function(newValue){ setTimeout(function(){ doWork(newValue); }, 0); }); 

If your doWork does many computations that will inevitably freeze UI. To avoid UI freezing you need write code so that computations are done in slices, so that UI can be updated. JavaScript scheduler will allow for UI update in between intervals. For example, if you are processing array, process items in chunks.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes but that way the only thing you achieve is to delay the calculation of computed variables. The UI still freezes while doing it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.