mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add config.unobserve()
This commit is contained in:
@@ -193,7 +193,7 @@ class Config
|
||||
# `callback` is fired whenever the value of the key is changed and will
|
||||
# be fired immediately unless the `callNow` option is `false`.
|
||||
#
|
||||
# keyPath - The {String} name of the key to watch
|
||||
# keyPath - The {String} name of the key to observe
|
||||
# options - An optional {Object} containing the `callNow` key.
|
||||
# callback - The {Function} that fires when the. It is given a single argument, `value`,
|
||||
# which is the new value of `keyPath`.
|
||||
@@ -212,10 +212,17 @@ class Config
|
||||
callback(value, {previous})
|
||||
|
||||
subscription = { cancel: => @off 'updated', updateCallback }
|
||||
@on 'updated', updateCallback
|
||||
@on "updated.#{keyPath.replace(/\./, '-')}", updateCallback
|
||||
callback(value) if options.callNow ? true
|
||||
subscription
|
||||
|
||||
|
||||
# Public: Unobserve all callbacks on a given key
|
||||
#
|
||||
# keyPath - The {String} name of the key to unobserve
|
||||
unobserve: (keyPath) ->
|
||||
@off("updated.#{keyPath.replace(/\./, '-')}")
|
||||
|
||||
# Private:
|
||||
update: ->
|
||||
return if @configFileHasErrors
|
||||
|
||||
Reference in New Issue
Block a user