startBatch
can.Observe.startBatch
Begin an event batch.
can.Observe.startBatch([batchStopHandler])
Parameters
-
batchStopHandler
{function()}
Optionala callback that gets called after all batched events have been called
Begin an event batch.
{function()}
Optionala callback that gets called after all batched events have been called
startBatch
causes can.Observe to begin an event batch. UntilstopBatch
is called, any events that would result from calls toattr
are held back from firing. If you have lots of changes to make to can.Observes, batching them together can help performance &emdash; especially if those can.Observes are live-bound to the DOM.In this example, you can see how the first and change events are not fired (and their handlers are not called) until
stopBatch
is called.You can also pass a callback to
startBatch
which will be called after all the events have been fired:Calling
startBatch
multiple timesIf you call
startBatch
more than once,stopBatch
needs to be called the same number of times before any batched events will fire. For ways to circumvent this process, see stopBatch.Here is an example that demonstrates how events are affected by calling
startBatch
multiple times.