428746bd by Michael Richards

Fix typos and issues related to unobserving array mutations.

1 parent 07f88cf7
...@@ -45,8 +45,9 @@ Rivets.adapters['.'] = ...@@ -45,8 +45,9 @@ Rivets.adapters['.'] =
45 map.pointers[ref].push keypath 45 map.pointers[ref].push keypath
46 46
47 unobserveMutations: (obj, ref, keypath) -> 47 unobserveMutations: (obj, ref, keypath) ->
48 if keyapths = @weakReference(obj).pointers?[ref] 48 if Array.isArray obj and obj[@id]?
49 keypaths.splice keypaths.indexOf(keypath), 1 49 if keypaths = @weakReference(obj).pointers?[ref]
50 keypaths.splice keypaths.indexOf(keypath), 1
50 51
51 subscribe: (obj, keypath, callback) -> 52 subscribe: (obj, keypath, callback) ->
52 callbacks = @weakReference(obj).callbacks 53 callbacks = @weakReference(obj).callbacks
...@@ -71,7 +72,7 @@ Rivets.adapters['.'] = ...@@ -71,7 +72,7 @@ Rivets.adapters['.'] =
71 unsubscribe: (obj, keypath, callback) -> 72 unsubscribe: (obj, keypath, callback) ->
72 callbacks = @weakmap[obj[@id]].callbacks[keypath] 73 callbacks = @weakmap[obj[@id]].callbacks[keypath]
73 callbacks.splice callbacks.indexOf(callback), 1 74 callbacks.splice callbacks.indexOf(callback), 1
74 @observeMutations obj[keypath], obj[@id], keypath 75 @unobserveMutations obj[keypath], obj[@id], keypath
75 76
76 read: (obj, keypath) -> 77 read: (obj, keypath) ->
77 obj[keypath] 78 obj[keypath]
......