Change observable but don't notify subscribers in knockout.js

后端 未结 4 1243
情歌与酒
情歌与酒 2020-11-28 05:33

Is there a way to ignore subscribers on a value change of the observable. Id like to change a value of an observable, but not execute it for the subscribers with knockout.j

4条回答
  •  一个人的身影
    2020-11-28 06:19

    I came to this question because I was building a paged datagrid. Only 10 rows were shown and each row has a checkbox. The table header had a (de)select all checkbox.

    During load tests we discovered that clicking the select all checkbox resulted in updating 1000 observables at once. This took way too long.

    It seemed that KO updated the html 1000 times even though only 10 observables were bound to HTML.

    If anyone finds this question for the same reason, I would suggest looking into deferred updates. Deferred updates queue notifying subscribers, it notifies your subscribers after your 'thread' is done. Deferred updates is configurable per observable or for your whole application.

    http://knockoutjs.com/documentation/deferred-updates.html

提交回复
热议问题