-
Notifications
You must be signed in to change notification settings - Fork 26
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
Ideas for new features of Blaze Components #139
Comments
Yes please!!
Not sure what this means? Also, there are so many ways to specify types of arguments... React PropTypes, Meteor Match, etc. which one do we use?
Perhaps
So should people use the React-style callback passing to set event handlers on children? |
In Blaze Components you have two types of data which can come to a component. One is what is passed to the component's constructor, another is which is currently a data context. The difference is that if the first arguments change, we recreate/reinitialize the component, if a second argument changes, only the state of the component changes, and things re-render reactivelly. Currently, you could pass or another, but not both. And now I am proposing that this is simply metadata of the argument, how it should be provided to the component (and which time).
None, as specified above, so that we do not force evaluation of a reactive function passed.
To me arguments is something you would add to your component inside a constructor. You should make sure you do not clobber any prototype method you have there anyway. And yes, we could check if a component has a prototype method defined the same as you defined that potentially arguments could be.
So, arguments can be functions. And so yea, you could do |
It would be great to have something like reacts componentDidUpdate, sometimes you have to use jQuery libs and stuff like this saves time (in the situations when you receive new data, but the template already rendered, but you need jQuery to do something with new data); It's quite hacky and not the intended way of properly doing things, but well, every time I hit this kind of situation I need to reinvent the wheel :) . |
@mitar everything looks awesome here, and I'm very excited to see public methods as one of the priorities. I'm not going to comment everything because I agree with all the changes, but I can suggest implementations (as a new but already heavy user view). One thing that we already created is a |
Isn't this the same as |
@stubailo
This way we know that this is a We are thinking about changing the method to something like this At least for us this makes a lot of sense. I can already think about some implications of this implementations. For example, what if I have multiple components rendered on the page? That means that all of them will share the same state? Maybe yes, maybe no. Does it makes sense for you now, @stubailo ? If no, I would love to hear maybe a simpler implementation that we can use. |
I guess that seems just as global, since it's just like saying |
When should this run? On every change? Of any attribute of any dom element?
Why don't you just use Minimongo/local collections on the client? It has nice things like easy limiting of reactivity, complex queries against data, and so on? You could have one document per component. You could in But anyway, this is for me orthogonal question to view layer. I do not think this should be part of the view layer, but it should just allow its use. Personally, I do not see the benefit of what you are proposing. But everyone has its own preferences here. |
Yeah, looks like I did it the wrong thing all the way, though I used the client-side collections. |
I am not yet completely sure how I would implement this, but I am thinking of doing some backwards incompatible changes to Blaze Components. In short, it is getting rid of a data context, instead of replacing it with scope.
{{> Component}}
would not pass data context anymore, scope of the included component would be empty{{> Component header=value}}
.header
becomes a reactive value (populated fromvalue
) inside the scope of theComponent
.value
is a function, and you pass it on, it would be great that it is passed on as a function){{> Component parent=this}}
, and then code inside could run something likethis.parent().fooBar()
iffooBar
is a method of the parent componentthis
inside a template would be now the component instance itselfparentComponent
and things like that would not be available anymore, component should get parent component explicitly as an argument, if it depends on it{{_privateHelper}}
, or should we do this?_
prefix on them), and some which are private to templates, and should not be called from outsidehash
there, it will just be an instance of known class{{value}}
will callvalue()
for you ifvalue
is a function, but{{fooBar value}}
will get you a functionvalue
as the first argument, ifvalue
is a function)What my plan is that I bump this package to 1.0 and release it. And then the above changes will be 2.0 of this package.
So the API of a component are arguments you can pass, and public methods you can call on the component. Events handlers are internal to the component.
cc @stubailo, because I think he will like some ideas here
The text was updated successfully, but these errors were encountered: