• function

End an event batch.

can.batch.stop([force[, callStart]])


  1. force=false {bool}Optional

    whether to stop batching events immediately

  2. callStart=false {bool}Optional

    whether to call can.batch.start after firing batched events

can.batch.stop matches an earlier can.batch.start call. If can.batch.stop has been called as many times as can.batch.start (or if force is true), all batched events will be fired and any callbacks passed to can.batch.start since the beginning of the batch will be called. If _force and callStart are both true, a new batch will be started when all the events and callbacks have been fired.

See can.batch.start for examples of can.batch.start and can.batch.stop in normal use.

In this example, the batch is forceably ended in the addPeople function.

var addPeople = function(observable) {
    observable.attr('a', 'Alice');
    observable.attr('b', 'Bob');
    observable.attr('e', 'Eve');

// In a completely different place:
var list = new can.Map();
list.bind('change', function() {
    console.log('The list changed.');

console.log('Still in the batch.');

// Here, the console has:
// Still in the batch.


// Here, the console has:
// The list changed.
// The list changed.
// The list changed.
// Still in the batch.