0

I have a Store with items. The store can receive several suspendEvents(true) and this will add to a counter each time it's called.

Example:

var myStore = //get store from somewhere
// myStore.eventsSuspended is 0

myStore.suspendEvents(true);
// myStore.eventsSuspended is 1

myStore.suspendEvents(true);
// myStore.eventsSuspended is 2

To resume events on the store resumeEvents() has to be called twice. I've been looking around in the docs. but can't find a clean way to call resumeEvents() and resume all events.

One of the solutions right know is:

do {
        myStore.resumeEvents();
    }
while (myStore.eventsSuspended > 0);

But it feels unsafe since if they change how this works in a later release this might cause unwanted behaviours that is hard to debug.

Any one got an idea on how to solve this?

4

1 回答 1

0

是的,这确实很危险,当另一段代码(例如布局管理器)暂停它们时,您的循环可能会调用恢复事件。

您需要确保每次调用时都调用 resumeevents 以暂停它们。它是这样构建的,因为 ext 代码中的模块化方法使得事件不会恢复,直到所有暂停事件的部分都触发了恢复。

于 2014-01-31T16:45:30.493 回答