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
startBatchcauses can.Observe to begin an event batch. UntilstopBatchis called, any events that would result from calls toattrare 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
stopBatchis called.You can also pass a callback to
startBatchwhich will be called after all the events have been fired:Calling
startBatchmultiple timesIf you call
startBatchmore than once,stopBatchneeds 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
startBatchmultiple times.