5d649eee by Michael Richards

s/setModel/setObserver. Store reference to the observer on the Rivets.Binding instance.

1 parent 1becef4e
...@@ -10,7 +10,7 @@ class Rivets.Binding ...@@ -10,7 +10,7 @@ class Rivets.Binding
10 @formatters = @options.formatters || [] 10 @formatters = @options.formatters || []
11 @dependencies = [] 11 @dependencies = []
12 @setBinder() 12 @setBinder()
13 @setModel() 13 @setObserver()
14 14
15 setBinder: => 15 setBinder: =>
16 unless @binder = @view.binders[@type] 16 unless @binder = @view.binders[@type]
...@@ -25,16 +25,16 @@ class Rivets.Binding ...@@ -25,16 +25,16 @@ class Rivets.Binding
25 @binder or= @view.binders['*'] 25 @binder or= @view.binders['*']
26 @binder = {routine: @binder} if @binder instanceof Function 26 @binder = {routine: @binder} if @binder instanceof Function
27 27
28 setModel: => 28 setObserver: =>
29 observer = new KeypathObserver @view, @view.models, @keypath, (target) => 29 @observer = new KeypathObserver @view, @view.models, @keypath, (target) =>
30 @unbind true if @key 30 @unbind true if @key
31 @model = target 31 @model = target
32 @bind true if @key 32 @bind true if @key
33 @sync() 33 @sync()
34 34
35 @rootKey = observer.root 35 @rootKey = @observer.root
36 @key = observer.key 36 @key = @observer.key
37 @model = observer.target 37 @model = @observer.target
38 38
39 # Applies all the current formatters to the supplied value and returns the 39 # Applies all the current formatters to the supplied value and returns the
40 # formatted value. 40 # formatted value.
...@@ -190,7 +190,7 @@ class Rivets.TextBinding extends Rivets.Binding ...@@ -190,7 +190,7 @@ class Rivets.TextBinding extends Rivets.Binding
190 constructor: (@view, @el, @type, @keypath, @options = {}) -> 190 constructor: (@view, @el, @type, @keypath, @options = {}) ->
191 @formatters = @options.formatters || [] 191 @formatters = @options.formatters || []
192 @dependencies = [] 192 @dependencies = []
193 @setModel() 193 @setObserver()
194 194
195 # A standard routine binder used for text node bindings. 195 # A standard routine binder used for text node bindings.
196 binder: 196 binder:
......