mirror of
https://github.com/atom/atom.git
synced 2026-02-10 14:45:11 -05:00
Add View#observeConfig as a space-pen extension
This commit is contained in:
committed by
Corey Johnson & Nathan Sobo
parent
97c6956e3f
commit
b91c353d2b
@@ -50,11 +50,14 @@ class Config
|
||||
observe: (keyPathString, callback) ->
|
||||
keyPath = keyPathString.split('.')
|
||||
value = @valueAtKeyPath(keyPath)
|
||||
@on 'update', =>
|
||||
updateCallback = =>
|
||||
newValue = @valueAtKeyPath(keyPath)
|
||||
unless newValue == value
|
||||
value = newValue
|
||||
callback(value)
|
||||
subscription = { destroy: => @off 'update', updateCallback }
|
||||
@on 'update', updateCallback
|
||||
callback(value)
|
||||
subscription
|
||||
|
||||
_.extend Config.prototype, EventEmitter
|
||||
|
||||
@@ -13,6 +13,7 @@ RootView = require 'root-view'
|
||||
Pasteboard = require 'pasteboard'
|
||||
require 'jquery-extensions'
|
||||
require 'underscore-extensions'
|
||||
require 'space-pen-extensions'
|
||||
|
||||
windowAdditions =
|
||||
rootViewParentSelector: 'body'
|
||||
|
||||
Reference in New Issue
Block a user