-
Notifications
You must be signed in to change notification settings - Fork 42
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
add I13nUtils mixin / add setParentNode in I13nNode #22
Conversation
CLA is valid! |
9d17f7c
to
429cc54
Compare
@@ -0,0 +1,40 @@ | |||
## I13nUtils | |||
|
|||
The `I13Utils` mixin provides util functions for you to access the i13n nodes and execute i13n functionalities |
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.
Why not just call it I13nMixin
?
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.
yeah, exactly, if you are using I13nMixin, we can access the i13nNode by accessing this._i13nNode
, but I think it's even better to have a function like this.getI13nNode()
I13Utils
is a subset of I13nMixin
, so using I13nMixin
can still get that function
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 think its confusing to have I13Utils and I13nMixin, its not clear when to use which one. Maybe just merge them and always use I13nMixin?
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.
if we combine that all the functionalities in a mixin, that mixin will always created a i13nNode for that component, and adding everything seems heavy if we just want some functionalities like executeI13nEvent
or getI13nNode
,
actually I didn't see any reason to expose I13nMixin to users, how about remove it from the document and get users to use createI13nNode
anyway?
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.
Thats fine if its not needed. It was mainly for components that didn't want to use createI13nNode right?
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.
yes, it's exposed for the components don't want to use createI13nNode
, so far as I know, people always use createI13nNode,
for me, createI13nNode
actually makes more sense for it's naming, (I13nMixin
doesn't provide enough information about what it does), and it let users to set options
easily https://github.com/yahoo/react-i13n/blob/master/docs/api/createI13nNode.md#createi13nnodecomponent-options,
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.
Sure, thats ok. So whats the end result here? Will I13Utils just become the mixin now?
so as our discussion,
|
updated according to previous comment, now using |
displayName: 'DemoComponent', | ||
render: function() { | ||
// this.props.i13n.getI13nNode() to access the i13nNode created by createI13nNode | ||
// this.props.executeEvent() to execute i13n event |
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.
shouldnt it be this.props.i13n.executeEvent
squash and 👍 Lets make sure all examples use the new |
add I13nUtils mixin / add setParentNode in I13nNode
@redonkulus @lingyan
provide
i13n utils mixins
for users to have a easier way to access i13n node and execute i13n event(move some shared functions to i13nUtils, to provide a small mixin for i13n functionalities)
getI13nNode
when we use
createI13nNode
to decorate a node, for examplecreateI13nNode(Foo)
, it generate a template likein Foo, we might have some case want to access the i13n node, so provide
getI13nNode
to get the nearest i13nNode in context passed from parents.In the end, they are do something like
executeI13nEvent
previously users will have to fire events like
now we provide executeI13nEvent for them, we can add some error handling and get the i13nNode into payload for them, (I will update all document that users should use this directly)
add setParentNode
Users might have case that they want to dynamically change the I13nTree structor, they can to that by changing parent node of some
I13nNode
this is actually for mail's use case, they have some component which is not a parent in the react dom tree, but they want to inherit the data of it, so that they can do this by changing the i13n tree structor.
Warning fix
break immediately when we don't have any handlers for the event, instead of showing something like
ReactI13n handler timeout in 1000ms. +951ms