mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-12 22:50:54 +03:00
When observing a key path, compare its new & old values structurally
This commit is contained in:
parent
a7d1a29748
commit
b82fe25b99
@ -25,13 +25,17 @@ describe "Config", ->
|
||||
config.get("foo.bar.baz").push("b")
|
||||
config.update()
|
||||
expect(observeHandler).toHaveBeenCalledWith config.get("foo.bar.baz")
|
||||
observeHandler.reset()
|
||||
|
||||
config.update()
|
||||
expect(observeHandler).not.toHaveBeenCalled()
|
||||
|
||||
describe ".observe(keyPath)", ->
|
||||
observeHandler = null
|
||||
|
||||
beforeEach ->
|
||||
observeHandler = jasmine.createSpy("observeHandler")
|
||||
config.foo = { bar: { baz: "value 1" } }
|
||||
config.set("foo.bar.baz", "value 1")
|
||||
config.observe "foo.bar.baz", observeHandler
|
||||
|
||||
it "fires the given callback with the current value at the keypath", ->
|
||||
|
@ -83,7 +83,7 @@ class Config
|
||||
previousValue = _.clone(value)
|
||||
updateCallback = =>
|
||||
value = @get(keyPath)
|
||||
unless value == previousValue
|
||||
unless _.isEqual(value, previousValue)
|
||||
previousValue = _.clone(value)
|
||||
callback(value)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user