mirror of
https://github.com/atom/atom.git
synced 2026-02-12 23:55:10 -05:00
Batch returns the function value
* Emit only one event for nested batches
This commit is contained in:
@@ -1146,9 +1146,13 @@ class TextEditor extends Model
|
||||
@batch => @buffer.transact(groupingInterval, fn)
|
||||
|
||||
batch: (fn) ->
|
||||
@emitter.emit "will-start-batch-operation"
|
||||
fn()
|
||||
@emitter.emit "did-finish-batch-operation"
|
||||
@batchCount++
|
||||
@emitter.emit "will-start-batch-operation" if @batchCount == 1
|
||||
value = fn()
|
||||
@emitter.emit "did-finish-batch-operation" if @batchCount == 1
|
||||
@batchCount--
|
||||
|
||||
value
|
||||
|
||||
onWillStartBatchOperation: (callback) ->
|
||||
@emitter.on "will-start-batch-operation", callback
|
||||
|
||||
Reference in New Issue
Block a user