-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[experimental] avoid initial double render #23
base: master
Are you sure you want to change the base?
Conversation
a8708dd
to
3de1a57
Compare
3de1a57
to
a111e67
Compare
|
||
export function registerReceiver(component) { | ||
let componentName = getComponentRegistryKey(component); | ||
REGISTERED_RECEIVERS[componentName] = component; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this fail if there's already a registered receiver for the component name?
I'm imagining a scenario where you have something like:
{{random-color-component onClick=(action foo)}}
...
Does the second component overwrite the first here?
// Many moons later another engineer adds
{{random-color-component onClick=(action bar)}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or is this scenario handled elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It currently does overwrite it. 👍 on raising an assertion, we can instruct to use a custom sendToName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another alternative is to map the name to multiple instances and send the action to all matching ones that are registered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the flexibility of keeping lists mapped to names:
{{my-component sendToName="foo"}}
{{my-component sendToName="foo"}}
{{my-component sendToName="bar"}}
{{my-component sendToName="bar"}}
Thus "name" becomes a group instead of a key.
I like the idea of a |
I like this approach. Code looks good to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that #24 landed, you should update the ember version badge in the readme.
This is an experimental approach for #18 which avoids an initial double render when using
InboundActions
.Instead of
InboundActions
, there is now aSender
andReceiver
mixin.actionReceiver
is no longer needed and we no longerset
anything in anafterRender
(which was the cause of the double render).If there are multiple components with the same name in a template, they can be given unique
actionReceiverName
s:TODO:
send-to
helper?actionReceiverName
tosendToName
/fyi @kellyselden I'd be interested to hear your thoughts on this approach