mirror of
https://github.com/atom/atom.git
synced 2026-02-09 14:15:24 -05:00
Add atom.project.observeBuffers
This makes `onDidAddBuffer` symmetrical with other `onDidAddX` methods and their `observeXs`. It also documents `onDidAddBuffer` and adds tests for it. Released under CC0.
This commit is contained in:
@@ -89,9 +89,27 @@ class Project extends Model
|
||||
onDidChangePaths: (callback) ->
|
||||
@emitter.on 'did-change-paths', callback
|
||||
|
||||
# Public: Invoke the given callback when a text buffer is added to the
|
||||
# project.
|
||||
#
|
||||
# * `callback` {Function} to be called when a text buffer is added.
|
||||
# * `buffer` A {TextBuffer} item.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onDidAddBuffer: (callback) ->
|
||||
@emitter.on 'did-add-buffer', callback
|
||||
|
||||
# Public: Invoke the given callback with all current and future text
|
||||
# buffers in the project.
|
||||
#
|
||||
# * `callback` {Function} to be called with current and future text buffers.
|
||||
# * `buffer` A {TextBuffer} item.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
observeBuffers: (callback) ->
|
||||
callback(buffer) for buffer in @getBuffers()
|
||||
@onDidAddBuffer callback
|
||||
|
||||
###
|
||||
Section: Accessing the git repository
|
||||
###
|
||||
|
||||
Reference in New Issue
Block a user