Make sure that we properly unsubscribe from any outdated portions of a keypath.
Showing
1 changed file
with
6 additions
and
6 deletions
... | @@ -15,15 +15,15 @@ class KeypathObserver | ... | @@ -15,15 +15,15 @@ class KeypathObserver |
15 | current = @view.adapters[@root.interface].read @view.models, @root.path | 15 | current = @view.adapters[@root.interface].read @view.models, @root.path |
16 | 16 | ||
17 | for token, index in @tokens | 17 | for token, index in @tokens |
18 | next = @view.adapters[token.interface].read current, token.path | ||
19 | |||
20 | if @objectPath[index]? | 18 | if @objectPath[index]? |
21 | if next isnt @objectPath[index] | 19 | if current isnt prev = @objectPath[index] |
22 | @view.adapters[token.interface].unsubscribe current, token.path, @update | 20 | @view.adapters[token.interface].unsubscribe prev, token.path, @update |
23 | @view.adapters[token.interface].subscribe next, token.path, @update | 21 | @view.adapters[token.interface].subscribe current, token.path, @update |
22 | @objectPath[index] = current | ||
24 | else | 23 | else |
25 | @view.adapters[token.interface].subscribe current, token.path, @update | 24 | @view.adapters[token.interface].subscribe current, token.path, @update |
25 | @objectPath[index] = current | ||
26 | 26 | ||
27 | current = next | 27 | current = @view.adapters[token.interface].read current, token.path |
28 | 28 | ||
29 | current | 29 | current | ... | ... |
-
Please register or sign in to post a comment