Use subscription to track if disabled packages are observed

This commit is contained in:
Kevin Sawicki 2014-02-10 09:16:31 -08:00
parent f0197632a3
commit 31a154d7eb

View File

@ -32,7 +32,6 @@ class PackageManager
@loadedPackages = {}
@activePackages = {}
@packageStates = {}
@observingDisabledPackages = false
@packageActivators = []
@registerPackageActivator(this, ['atom', 'textmate'])
@ -129,14 +128,11 @@ class PackageManager
@getActivePackage(name)?
unobserveDisabledPackages: ->
return unless @observingDisabledPackages
atom.config.unobserve('core.disabledPackages')
@observingDisabledPackages = false
@disabledPackagesSubscription?.off()
@disabledPackagesSubscription = null
observeDisabledPackages: ->
return if @observingDisabledPackages
atom.config.observe 'core.disabledPackages', callNow: false, (disabledPackages, {previous}) =>
@disabledPackagesSubscription ?= atom.config.observe 'core.disabledPackages', callNow: false, (disabledPackages, {previous}) =>
packagesToEnable = _.difference(previous, disabledPackages)
packagesToDisable = _.difference(disabledPackages, previous)
@ -144,8 +140,6 @@ class PackageManager
@activatePackage(packageName) for packageName in packagesToEnable
null
@observingDisabledPackages = true
loadPackages: ->
# Ensure atom exports is already in the require cache so the load time
# of the first package isn't skewed by being the first to require atom