cd102889 by Michael Richards

Make sure that we unsubscribe the whole keypath observer when unbinding a binding for good. [#223]

1 parent f35223d4
...@@ -107,7 +107,10 @@ class Rivets.Binding ...@@ -107,7 +107,10 @@ class Rivets.Binding
107 107
108 # Unsubscribes from the model and the element. 108 # Unsubscribes from the model and the element.
109 unbind: (silent = false) => 109 unbind: (silent = false) =>
110 @binder.unbind?.call @, @el unless silent 110 unless silent
111 @binder.unbind?.call @, @el
112 @observer.unobserve()
113
111 @view.adapters[@key.interface].unsubscribe(@model, @key.path, @sync) if @key 114 @view.adapters[@key.interface].unsubscribe(@model, @key.path, @sync) if @key
112 115
113 if @dependencies.length 116 if @dependencies.length
......
...@@ -39,3 +39,8 @@ class KeypathObserver ...@@ -39,3 +39,8 @@ class KeypathObserver
39 current = @view.adapters[token.interface].read current, token.path 39 current = @view.adapters[token.interface].read current, token.path
40 40
41 current 41 current
42
43 unobserve: =>
44 for token, index in @tokens
45 if obj = @objectPath[index]
46 @view.adapters[token.interface].unsubscribe obj, token.path, @update
......