Merge lp://staging/~gary/juju-gui/nodeChangeHandler into lp://staging/juju-gui/experimental

Proposed by Gary Poster
Status: Merged
Merged at revision: 1027
Proposed branch: lp://staging/~gary/juju-gui/nodeChangeHandler
Merge into: lp://staging/juju-gui/experimental
Diff against target: 282 lines (+93/-51)
5 files modified
app/views/databinding.js (+40/-12)
app/views/inspector.js (+1/-1)
test/test_databinding.js (+49/-35)
test/test_inspector_constraints.js (+1/-1)
test/test_inspector_settings.js (+2/-2)
To merge this branch: bzr merge lp://staging/~gary/juju-gui/nodeChangeHandler
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+184901@code.staging.launchpad.net

Description of the change

Refactor and rename BindingEngine._storeChanged

This is a small clean-up branch in preparation to cleaning up some of the conflict resolution edge cases. It is largely about refactoring and renaming BindingEngine._storeChanged.

* BindingEngine._storeChanged is now called _nodeChangeHandler.
* That method simply calls out to the new method _nodeChanged. It takes a node rather than an event with a node.
* Factored _getBinding out of _nodeChanged to make the code read better and to test the functionality independently.
* Adjusted tests to use _nodeChanged.
* Refactored tests to reuse more code and clean up some lint.
* Added tests for _getBinding.

In addition to those related changes, I made one more peripheral change: I removed an unused argument to unsyncedFields.

https://codereview.appspot.com/13265045/

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

Reviewers: mp+184901_code.launchpad.net,

Message:
Please take a look.

Description:
Refactor and rename BindingEngine._storeChanged

This is a small clean-up branch in preparation to cleaning up some of
the conflict resolution edge cases. It is largely about refactoring and
renaming BindingEngine._storeChanged.

* BindingEngine._storeChanged is now called _nodeChangeHandler.
* That method simply calls out to the new method _nodeChanged. It takes
a node rather than an event with a node.
* Factored _getBinding out of _nodeChanged to make the code read better
and to test the functionality independently.
* Adjusted tests to use _nodeChanged.
* Refactored tests to reuse more code and clean up some lint.
* Added tests for _getBinding.

In addition to those related changes, I made one more peripheral change:
I removed an unused argument to unsyncedFields.

There's not much to QA here. It's just moving bits of code around.

https://code.launchpad.net/~gary/juju-gui/nodeChangeHandler/+merge/184901

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/13265045/

Affected files (+95, -51 lines):
   A [revision details]
   M app/views/databinding.js
   M app/views/inspector.js
   M test/test_databinding.js
   M test/test_inspector_constraints.js
   M test/test_inspector_settings.js

Revision history for this message
Benjamin Saller (bcsaller) wrote :

LGTM, minor suggestions, take it or leave it, thanks for the cleanups

https://codereview.appspot.com/13265045/diff/1/app/views/databinding.js
File app/views/databinding.js (right):

https://codereview.appspot.com/13265045/diff/1/app/views/databinding.js#newcode668
app/views/databinding.js:668: @return {Binding} Binding reference.
This is a case, but not the only one, a single model key can have more
than one node bound and thus more than one binding. Depending on your
use case this maybe ok, but I suspect you'd always want to return an
array of all bindings for a given key.

The other option that works with the current code is to also pass a node
target, and say get the binding for (key) where binding.target ===
target. This should always be one.

https://codereview.appspot.com/13265045/diff/1/app/views/databinding.js#newcode711
app/views/databinding.js:711: if (nodeHandler.eq(node,
binding.get(model))) {
This reads nicely now, thank you. See the notes about getBinding though

https://codereview.appspot.com/13265045/diff/1/test/test_databinding.js
File test/test_databinding.js (right):

https://codereview.appspot.com/13265045/diff/1/test/test_databinding.js#newcode35
test/test_databinding.js:35: };
nice cleanup, I'd be tempted to add 'options' to the arguments and mix
it in object create to allow add/overwrite viewlet code but you contain
a superset of what the tests need so no worries.

https://codereview.appspot.com/13265045/

Revision history for this message
Gary Poster (gary) wrote :

On 2013/09/11 01:37:51, benjamin.saller wrote:
> LGTM, minor suggestions, take it or leave it, thanks for the cleanups

https://codereview.appspot.com/13265045/diff/1/app/views/databinding.js
> File app/views/databinding.js (right):

https://codereview.appspot.com/13265045/diff/1/app/views/databinding.js#newcode668
> app/views/databinding.js:668: @return {Binding} Binding reference.
> This is a case, but not the only one, a single model key can have more
than one
> node bound and thus more than one binding. Depending on your use case
this maybe
> ok, but I suspect you'd always want to return an array of all bindings
for a
> given key.

> The other option that works with the current code is to also pass a
node target,
> and say get the binding for (key) where binding.target === target.
This should
> always be one.

Ah! Great point, thank you. I'll take the second route. That's what
this use case needs.

https://codereview.appspot.com/13265045/diff/1/app/views/databinding.js#newcode711
> app/views/databinding.js:711: if (nodeHandler.eq(node,
binding.get(model))) {
> This reads nicely now, thank you. See the notes about getBinding
though

https://codereview.appspot.com/13265045/diff/1/test/test_databinding.js
> File test/test_databinding.js (right):

https://codereview.appspot.com/13265045/diff/1/test/test_databinding.js#newcode35
> test/test_databinding.js:35: };
> nice cleanup, I'd be tempted to add 'options' to the arguments and mix
it in
> object create to allow add/overwrite viewlet code but you contain a
superset of
> what the tests need so no worries.

Yeah, I like that idea, but I'll leave that to The Future. :-)

Thank you!

https://codereview.appspot.com/13265045/

Revision history for this message
Gary Poster (gary) wrote :

*** Submitted:

Refactor and rename BindingEngine._storeChanged

This is a small clean-up branch in preparation to cleaning up some of
the conflict resolution edge cases. It is largely about refactoring and
renaming BindingEngine._storeChanged.

* BindingEngine._storeChanged is now called _nodeChangeHandler.
* That method simply calls out to the new method _nodeChanged. It takes
a node rather than an event with a node.
* Factored _getBinding out of _nodeChanged to make the code read better
and to test the functionality independently.
* Adjusted tests to use _nodeChanged.
* Refactored tests to reuse more code and clean up some lint.
* Added tests for _getBinding.

In addition to those related changes, I made one more peripheral change:
I removed an unused argument to unsyncedFields.

R=benjamin.saller
CC=
https://codereview.appspot.com/13265045

https://codereview.appspot.com/13265045/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches