mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-07 23:59:22 +03:00
Revert "Add Project::observeBuffers"
This reverts commit b6fe72ef9e
.
Conflicts:
src/project.coffee
This commit is contained in:
parent
6a0a842de4
commit
61fa1c4230
@ -479,7 +479,7 @@ describe "Project", ->
|
||||
runs ->
|
||||
expect(results).toHaveLength 0
|
||||
|
||||
describe ".observeBuffers(callback)", ->
|
||||
describe ".eachBuffer(callback)", ->
|
||||
beforeEach ->
|
||||
atom.project.bufferForPathSync('a')
|
||||
|
||||
@ -490,7 +490,7 @@ describe "Project", ->
|
||||
callback = (buffer) ->
|
||||
callbackBuffer = buffer
|
||||
count++
|
||||
atom.project.observeBuffers(callback)
|
||||
atom.project.eachBuffer(callback)
|
||||
expect(count).toBe 1
|
||||
expect(callbackBuffer).toBe atom.project.getBuffers()[0]
|
||||
|
||||
@ -501,7 +501,7 @@ describe "Project", ->
|
||||
callbackBuffer = buffer
|
||||
count++
|
||||
|
||||
atom.project.observeBuffers(callback)
|
||||
atom.project.eachBuffer(callback)
|
||||
count = 0
|
||||
callbackBuffer = null
|
||||
atom.project.bufferForPathSync(require.resolve('./fixtures/sample.txt'))
|
||||
|
@ -98,7 +98,7 @@ class Git
|
||||
@refreshStatus()
|
||||
|
||||
if @project?
|
||||
@subscribe @project.observeBuffers (buffer) => @subscribeToBuffer(buffer)
|
||||
@subscribe @project.eachBuffer (buffer) => @subscribeToBuffer(buffer)
|
||||
|
||||
###
|
||||
Section: Event Subscription
|
||||
|
@ -54,15 +54,6 @@ class Project extends Model
|
||||
onDidChangePath: (callback) ->
|
||||
@emitter.on 'did-change-path', callback
|
||||
|
||||
# Extended: Immediately invoke the given callback for all existing buffers.
|
||||
# Then invoke the given callback when a new buffer has been created. For
|
||||
# example, when {::open} is called, this is fired.
|
||||
#
|
||||
# * `callback` {Function}
|
||||
# * `buffer` {TextBuffer} the new buffer
|
||||
observeBuffers: (callback) ->
|
||||
callback(buffer) for buffer in @getBuffers()
|
||||
@onDidCreateBuffer(callback)
|
||||
|
||||
# Extended: Invoke the given callback when a new buffer has been created. For
|
||||
# example, when {::open} is called, this is fired.
|
||||
@ -363,12 +354,11 @@ class Project extends Model
|
||||
subscriber = args.shift() if args.length > 1
|
||||
callback = args.shift()
|
||||
|
||||
message = 'Use Project::observeBuffers instead'
|
||||
message += '; Project::observeBuffers no longer accepts a subscriber parameter. Call `subscriber.subscribe(atom.project.observeBuffers(cb))`' if subscriber?
|
||||
|
||||
disposable = @observeBuffers(callback)
|
||||
subscriber.subscribe(disposable) if subscriber?
|
||||
disposable
|
||||
callback(buffer) for buffer in @getBuffers()
|
||||
if subscriber
|
||||
subscriber.subscribe this, 'buffer-created', (buffer) -> callback(buffer)
|
||||
else
|
||||
@on 'buffer-created', (buffer) -> callback(buffer)
|
||||
|
||||
# Deprecated: delegate
|
||||
registerOpener: (opener) ->
|
||||
|
Loading…
Reference in New Issue
Block a user