Remove the adapter bypass feature completely, and hard code to the default adapter for now. [#178]
Showing
1 changed file
with
11 additions
and
27 deletions
... | @@ -74,10 +74,7 @@ class Rivets.Binding | ... | @@ -74,10 +74,7 @@ class Rivets.Binding |
74 | 74 | ||
75 | # Syncs up the view binding with the model. | 75 | # Syncs up the view binding with the model. |
76 | sync: => | 76 | sync: => |
77 | @set if @options.bypass | 77 | @set @view.adapters['.'].read @model, @keypath |
78 | @model[@keypath] | ||
79 | else | ||
80 | @view.config.adapter.read @model, @keypath | ||
81 | 78 | ||
82 | # Publishes the value currently set on the input element back to the model. | 79 | # Publishes the value currently set on the input element back to the model. |
83 | publish: => | 80 | publish: => |
... | @@ -90,19 +87,15 @@ class Rivets.Binding | ... | @@ -90,19 +87,15 @@ class Rivets.Binding |
90 | if @view.formatters[id]?.publish | 87 | if @view.formatters[id]?.publish |
91 | value = @view.formatters[id].publish value, args... | 88 | value = @view.formatters[id].publish value, args... |
92 | 89 | ||
93 | @view.config.adapter.publish @model, @keypath, value | 90 | @view.adapters['.'].publish @model, @keypath, value |
94 | 91 | ||
95 | # Subscribes to the model for changes at the specified keypath. Bi-directional | 92 | # Subscribes to the model for changes at the specified keypath. Bi-directional |
96 | # routines will also listen for changes on the element to propagate them back | 93 | # routines will also listen for changes on the element to propagate them back |
97 | # to the model. | 94 | # to the model. |
98 | bind: => | 95 | bind: => |
99 | @binder.bind?.call @, @el | 96 | @binder.bind?.call @, @el |
100 | 97 | @view.adapters['.'].subscribe @model, @keypath, @sync | |
101 | if @options.bypass | 98 | @sync() if @view.config.preloadData |
102 | @sync() | ||
103 | else | ||
104 | @view.config.adapter.subscribe @model, @keypath, @sync | ||
105 | @sync() if @view.config.preloadData | ||
106 | 99 | ||
107 | if @options.dependencies?.length | 100 | if @options.dependencies?.length |
108 | for dependency in @options.dependencies | 101 | for dependency in @options.dependencies |
... | @@ -114,14 +107,12 @@ class Rivets.Binding | ... | @@ -114,14 +107,12 @@ class Rivets.Binding |
114 | model = @view.models[dependency.shift()] | 107 | model = @view.models[dependency.shift()] |
115 | keypath = dependency.join '.' | 108 | keypath = dependency.join '.' |
116 | 109 | ||
117 | @view.config.adapter.subscribe model, keypath, @sync | 110 | @view.adapters['.'].subscribe model, keypath, @sync |
118 | 111 | ||
119 | # Unsubscribes from the model and the element. | 112 | # Unsubscribes from the model and the element. |
120 | unbind: => | 113 | unbind: => |
121 | @binder.unbind?.call @, @el | 114 | @binder.unbind?.call @, @el |
122 | 115 | @view.adapters['.'].unsubscribe @model, @keypath, @sync | |
123 | unless @options.bypass | ||
124 | @view.config.adapter.unsubscribe @model, @keypath, @sync | ||
125 | 116 | ||
126 | if @options.dependencies?.length | 117 | if @options.dependencies?.length |
127 | for dependency in @options.dependencies | 118 | for dependency in @options.dependencies |
... | @@ -133,23 +124,17 @@ class Rivets.Binding | ... | @@ -133,23 +124,17 @@ class Rivets.Binding |
133 | model = @view.models[dependency.shift()] | 124 | model = @view.models[dependency.shift()] |
134 | keypath = dependency.join '.' | 125 | keypath = dependency.join '.' |
135 | 126 | ||
136 | @view.config.adapter.unsubscribe model, keypath, @sync | 127 | @view.adapters['.'].unsubscribe model, keypath, @sync |
137 | 128 | ||
138 | # Updates the binding's model from what is currently set on the view. Unbinds | 129 | # Updates the binding's model from what is currently set on the view. Unbinds |
139 | # the old model first and then re-binds with the new model. | 130 | # the old model first and then re-binds with the new model. |
140 | update: (models = {}) => | 131 | update: (models = {}) => |
141 | if @key | 132 | if @key |
142 | if models[@key] | 133 | if models[@key] |
143 | unless @options.bypass | 134 | @view.adapters['.'].unsubscribe @model, @keypath, @sync |
144 | @view.config.adapter.unsubscribe @model, @keypath, @sync | ||
145 | |||
146 | @model = models[@key] | 135 | @model = models[@key] |
147 | 136 | @view.adapters['.'].subscribe @model, @keypath, @sync | |
148 | if @options.bypass | 137 | @sync() if @view.config.preloadData |
149 | @sync() | ||
150 | else | ||
151 | @view.config.adapter.subscribe @model, @keypath, @sync | ||
152 | @sync() if @view.config.preloadData | ||
153 | else | 138 | else |
154 | @sync() | 139 | @sync() |
155 | 140 | ||
... | @@ -268,9 +253,8 @@ class Rivets.View | ... | @@ -268,9 +253,8 @@ class Rivets.View |
268 | pipes = (pipe.trim() for pipe in declaration.split '|') | 253 | pipes = (pipe.trim() for pipe in declaration.split '|') |
269 | context = (ctx.trim() for ctx in pipes.shift().split '<') | 254 | context = (ctx.trim() for ctx in pipes.shift().split '<') |
270 | path = context.shift() | 255 | path = context.shift() |
271 | splitPath = path.split /\.|:/ | 256 | splitPath = path.split '.' |
272 | options.formatters = pipes | 257 | options.formatters = pipes |
273 | options.bypass = path.indexOf(':') != -1 | ||
274 | 258 | ||
275 | if splitPath[0] | 259 | if splitPath[0] |
276 | key = splitPath.shift() | 260 | key = splitPath.shift() | ... | ... |
-
Please register or sign in to post a comment