Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(77)

Issue 43700043: NodeBind: oneTime (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 4 months ago by rafaelw
Modified:
12 years, 4 months ago
Reviewers:
arv, rafaelw1, John Messerly
CC:
justin
Base URL:
https://github.com/Polymer/NodeBind.git@master
Visibility:
Public.

Description

NodeBind: oneTime. This patch changes the call signature of bind(), which now takes: name, value, oneTime. oneTime is expected to be true if the caller wishes the bound value updated but doesn't require it to track an observable. if oneTime is true, it is expected that value will NOT be an observable, otherwise it will be. R=arv BUG= Committed: https://github.com/Polymer/NodeBind/commit/b9266f7

Patch Set 1 #

Patch Set 2 : sync #

Total comments: 7

Patch Set 3 : cr comments #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+109 lines, -34 lines) Patch
M src/NodeBind.js View 1 2 5 chunks +51 lines, -34 lines 1 comment Download
M tests/tests.js View 8 chunks +58 lines, -0 lines 0 comments Download

Messages

Total messages: 7
rafaelw
12 years, 4 months ago (2013-12-18 20:01:29 UTC) #1
arv
https://codereview.appspot.com/43700043/diff/20001/src/NodeBind.js File src/NodeBind.js (right): https://codereview.appspot.com/43700043/diff/20001/src/NodeBind.js#newcode108 src/NodeBind.js:108: return Node.prototype.bind.call(this, name, value); Pass along oneTime? https://codereview.appspot.com/43700043/diff/20001/src/NodeBind.js#newcode343 src/NodeBind.js:343: ...
12 years, 4 months ago (2013-12-18 20:18:34 UTC) #2
rafaelw
https://codereview.appspot.com/43700043/diff/20001/src/NodeBind.js File src/NodeBind.js (right): https://codereview.appspot.com/43700043/diff/20001/src/NodeBind.js#newcode108 src/NodeBind.js:108: return Node.prototype.bind.call(this, name, value); Good catch. Thank you. Fixed ...
12 years, 4 months ago (2013-12-18 20:46:19 UTC) #3
rafaelw
Committed patchset #3 manually as rb9266f7 (presubmit successful).
12 years, 4 months ago (2013-12-18 20:46:38 UTC) #4
John Messerly
https://codereview.appspot.com/43700043/diff/40001/src/NodeBind.js File src/NodeBind.js (right): https://codereview.appspot.com/43700043/diff/40001/src/NodeBind.js#newcode106 src/NodeBind.js:106: Text.prototype.bind = function(name, value, oneTime) { It seems like ...
12 years, 4 months ago (2013-12-19 03:53:34 UTC) #5
rafaelw1
On Wed, Dec 18, 2013 at 7:53 PM, <jmesserly@google.com> wrote: > > https://codereview.appspot.com/43700043/diff/40001/src/NodeBind.js > File ...
12 years, 4 months ago (2014-01-07 23:28:43 UTC) #6
John Messerly
12 years, 4 months ago (2014-01-07 23:58:39 UTC) #7
Yeah that sounds like a good approach.


On Tue, Jan 7, 2014 at 3:28 PM, Rafael Weinstein <rafaelw@google.com> wrote:

> On Wed, Dec 18, 2013 at 7:53 PM, <jmesserly@google.com> wrote:
>
>>
>> https://codereview.appspot.com/43700043/diff/40001/src/NodeBind.js
>> File src/NodeBind.js (right):
>>
>> https://codereview.appspot.com/43700043/diff/40001/src/
>> NodeBind.js#newcode106
>> src/NodeBind.js:106: Text.prototype.bind = function(name, value,
>> oneTime) {
>> It seems like the behavior of oneTime vs not one time is fairly
>> different. (The fact that the "value" parameter can be two distinct
>> kinds of things is a good indication.) Is there a way to structure this
>> differently, perhaps as two methods?
>>
>>
> I totally understand the criticism. I can also see how this API makes less
> sense in a typed world. I'm somewhat disinclined to polish this API at the
> moment -- mainly out of fear or regressing perf but also because I haven't
> seen any actual uses of one-time bindings in the wild yet.
>
> If no one uses the feature, we should just remove it -- rather than
> investing more time in it.
>
>
>> Currently the pattern seems to be:
>>
>>     if (... matches a property ...) {
>>       if (oneTime) return updateProperty(name, value);
>>
>>       this.unbind(name);
>>       // note: the actual code uses more optimized closures
>>       var self = this;
>>       updateProperty(name, value.open(function(x) {
>>         updateProperty(self, name, x);
>>       }));
>>       return this.bindings[name] = value;
>>     } else {
>>       return super.bind(...);
>>     }
>>
>> Could updateProperty be a distinct method? That way, oneTime bindings
>> are handled without needing a boolean, and observable bindings build on
>> the updateProperty primitive.
>>
>> (Something would have to be done about the removeAttribute logic. It
>> feels very boilerplate-ish right now. IMHO, I'd move it out of either
>> method and make it a concern of TemplateBinding, since it has the job of
>> parsing the attributes.)
>>
>> https://codereview.appspot.com/43700043/
>>
>
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b