fix(data-source): Wait until the next cycle to cleanup

Fixes a crash when switching to the thread list from the draft list, where there are very briefly zero observers.
This commit is contained in:
Ben Gotow 2016-09-29 13:42:52 -07:00
parent 1e9d1dff07
commit c222fa0c39

View file

@ -26,9 +26,10 @@ class ListDataSource
return => return =>
@_emitter.removeListener('trigger', eventHandler) @_emitter.removeListener('trigger', eventHandler)
if @_emitter.listenerCount('trigger') is 0 process.nextTick =>
@_cleanedup = true if @_emitter.listenerCount('trigger') is 0
@cleanup() @_cleanedup = true
@cleanup()
loaded: -> loaded: ->
throw new Error("ListDataSource base class does not implement loaded()") throw new Error("ListDataSource base class does not implement loaded()")