• function

stopBatch can.Observe.stopBatch


End an event batch.

can.Observe.stopBatch([force[, callStart]])


  1. force=false {bool}Optional

    whether to stop batching events immediately

  2. callStart=false {bool}Optional

    whether to call startBatch after firing batched events

stopBatch matches an earlier can.Observe.startBatch call. If stopBatch has been called as many times as startBatch (or if force is true), all batched events will be fired and any callbacks passed to startBatch 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.Observe.startBatch for examples of startBatch and stopBatch 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.Observe();
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.