These are chat archives for ractivejs/ractive

16th
Jan 2018
Chris Reeves
@evs-chris
Jan 16 2018 05:36
I've started a 0.10 branch and merged in the await branch
after some wailing and gnashing of teeth, travis has graciously decided to publish it for us as v0.10-dev
Paul Maly
@PaulMaly_twitter
Jan 16 2018 05:41
Thanks! :+1:
Joseph
@fskreuz
Jan 16 2018 14:00

after some wailing and gnashing of teeth

:scream:

Joseph
@fskreuz
Jan 16 2018 14:29
Random question of the day: When you subclass/extend a component, out of instinct, what do you expect it to do if you supply it a template? What happens to the parent template? What happens to the child template?
Paul Maly
@PaulMaly_twitter
Jan 16 2018 14:34
Seems, child template replace parent template.
Chris Reeves
@evs-chris
Jan 16 2018 15:02
Yep, child overrides parent is what I expect.
I'm with Rich, extending components is probably not what you want to do in the general case. You have to be really careful in order to not shoot yourself in the foot.
Paul Maly
@PaulMaly_twitter
Jan 16 2018 15:13
One additional case, which I see and it's could be interesting: if child template is a function, so maybe it's could be useful to have parent template available inside it. For example:
Component.extend({
     template: function() {
          return this._super() + '<p>Child specific html</p>';
     }
});
Chris Reeves
@evs-chris
Jan 16 2018 15:57
The problem with that is that the default format for templates at that point in the lifecycle is AST, so you'd end up with [object Array]<p>Child specific html</p>.
also, some components never have a stringy template if they have a build process
I try to avoid stringy templates and the associated parsing overhead everywhere but demos
Paul Maly
@PaulMaly_twitter
Jan 16 2018 17:06
But we can just try to do his: return this._super().concat(Ractive.parse().t) isn't?
And make template function return not only string but also AST
Anyway, it's just proposal, so in general I never need this before
But seems, it could be useful in some cases
Anatoli Radulov
@avoto
Jan 16 2018 18:23
Hi everyone, I've been trying to find the best way to achieve something like this: <component isolated="false" .../>. My thoughts were around hooking the logic to wire the value during onconstruct but I am not very sure if this is a good approach... I am trying to have a way for a component to be isolated by default but with an option given certain case to be non-isolated.
Paul Maly
@PaulMaly_twitter
Jan 16 2018 18:26
Anchors?
Actually, I think we need some good way to pass the options to components tags.
Chris Reeves
@evs-chris
Jan 16 2018 18:27
I'd say set it as an attribute and check it at onconfig
you should be able to this.isolated = false there
Anatoli Radulov
@avoto
Jan 16 2018 18:50
I see. That worked great. Thanks for the hint!
Paul Maly
@PaulMaly_twitter
Jan 16 2018 19:12
@evs-chris Thank you very much for the await-block! I already re-wrote my code using it and it's absolutely awesome! I also removed about 100 line of my own code which implemented similar functionality and it has made my code much cleaner!
Chris Reeves
@evs-chris
Jan 16 2018 19:29
:+1:
Joseph
@fskreuz
Jan 16 2018 23:29
re: subclassing, I was just wondering if someone would respond with "embed child template in parent" or "wrap parent around child" or "yield something somewhere". Somewhere along the lines of layout extension and content blocks (i.e. "template extends another template, this markup goes in block with this name").
But if composition is the main mode of reuse, why was extend made available to component constructors?
Paul Maly
@PaulMaly_twitter
Jan 16 2018 23:38
I think extend is about inheritance of business logic rather than templates. But composition is for templates.
Paul Maly
@PaulMaly_twitter
Jan 16 2018 23:44
For me the components are more about business logic too. That why I don't use Single File Components approach in Ractive. I don't think, that my component's behavior need to be strictly related to some template.
Sometimes my components has a different templates based on their names.
Chris Reeves
@evs-chris
Jan 16 2018 23:53
Also, partials and styles are handy when inherited. Anecdotally, it rarely makes sense to have anything more than an abstract component base to inherit from.
I use the single file format, but with the bin as es modules so that I can also pull in common logic and additional components from other modules in the same codebase.