Use disposables for removing properties

This commit is contained in:
Ben Ogle 2014-10-02 13:49:30 -07:00
parent e2ac19c17f
commit a8fad6a0fb
4 changed files with 10 additions and 8 deletions

View File

@ -335,6 +335,9 @@ describe "PackageManager", ->
expect(atom.config.get(['.source.ruby'], 'editor.commentStart')).toBe '# '
describe "::deactivatePackage(id)", ->
afterEach ->
atom.packages.unloadPackages()
describe "atom packages", ->
it "calls `deactivate` on the package's main module if activate was successful", ->
pack = null

View File

@ -717,10 +717,6 @@ class Config
.join(' ')
@scopedSettingsStore.getProperties(scopeChain, keyPath)
removeScopedSettingsForName: (name) ->
@scopedSettingsStore.removeProperties(name)
@scopedSettingsStore.removeProperties("#{name}+default")
clearScopedSettings: ->
@scopedSettingsStore = new ScopedPropertyStore

View File

@ -1,4 +1,5 @@
CSON = require 'season'
{CompositeDisposable} = require 'event-kit'
module.exports =
class ScopedProperties
@ -10,10 +11,12 @@ class ScopedProperties
callback(null, new ScopedProperties(scopedPropertiesPath, scopedProperties))
constructor: (@path, @scopedProperties) ->
@propertyDisposable = new CompositeDisposable
activate: ->
for selector, properties of @scopedProperties
atom.config.addScopedDefaults(@path, selector, properties)
@propertyDisposable.add atom.config.addScopedDefaults(@path, selector, properties)
return
deactivate: ->
atom.config.removeScopedSettingsForName(@path)
@propertyDisposable.dispose()

View File

@ -44,8 +44,8 @@ class Syntax extends GrammarRegistry
atom.config.addScopedDefaults(args...)
removeProperties: (name) ->
deprecate 'A direct (but private) replacement is available at atom.config.removeScopedSettingsForName().'
atom.config.removeScopedSettingsForName(name)
deprecate 'atom.config.addScopedDefaults() now returns a disposable you can call .dispose() on'
atom.config.scopedSettingsStore.removeProperties(name)
clearProperties: ->
deprecate 'A direct (but private) replacement is available at atom.config.clearScopedSettings().'