Batch multiple view updates with Editor::batchUpdates

This commit is contained in:
Nathan Sobo
2014-04-15 13:13:53 -06:00
parent fe6a007774
commit ddc677fb30
2 changed files with 26 additions and 3 deletions

View File

@@ -1781,7 +1781,9 @@ class Editor extends Model
# execution and revert any changes performed up to the abortion.
#
# fn - A {Function} to call inside the transaction.
transact: (fn) -> @buffer.transact(fn)
transact: (fn) ->
@batchUpdates =>
@buffer.transact(fn)
# Public: Start an open-ended transaction.
#
@@ -1801,6 +1803,11 @@ class Editor extends Model
# within the transaction.
abortTransaction: -> @buffer.abortTransaction()
batchUpdates: (fn) ->
@emit 'batched-updates-started'
fn()
@emit 'batched-updates-ended'
inspect: ->
"<Editor #{@id}>"