start
Begin an event batch.
can.batch.start([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
can.batch.start
causes can.Map to begin an event batch. Untilcan.batch.stop
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.Maps, batching them together can help performance &emdash; especially if those can.Maps 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
can.batch.stop
is called.You can also pass a callback to
can.batch.start
which will be called after all the events have been fired:Calling
can.batch.start
multiple timesIf you call
can.batch.start
more than once,can.batch.stop
needs to be called the same number of times before any batched events will fire. For ways to circumvent this process, see can.batch.stop.Here is an example that demonstrates how events are affected by calling
can.batch.start
multiple times.