Hi guys,
pre-print: I consider myself a javascript & meteor newbie and I am just working on my first big app.
I totally fell in love with Blaze Components (big thumbs up to @mitar) https://github.com/peerlibrary/meteor-blaze-components
and I am so confused by the whole React discussion. Hierby I vote for MDG keeping full Blaze-Support within core.
Why not simply have Blaze Components as the NEW Blaze?
Blaze was what originally draw me into Meteor and with the help of “Blaze Components” I am able to bring my app to the next level and keep it DRY.
I much prefer the syntax of Blaze Components and have NO intentions to switch to react as I don’t need react native support.
Is anyone else feeling like Blaze Components should be kept close to core?
I mean: this demo-code here shows all I need to structure my app really well into reusable components:
JS
// ===================
// COUNTER Super-Mixin
class CounterSuperComponent extends BlazeComponent {
// COMMON template for Mixins
template() { return 'CounterSuperComponentTemplate'; }
constructor(settings) {
super();
var self = this;
self.title = settings.title;
self.counter = ReactiveField(0);
}
events() {
return super.events().concat({
'click': this.onClick,
});
}
onClick(event) {
var self = this;
log('click');
self.counter(self.counter() + 1);
}
theGlobalCount() {
var self = this;
return self.parentComponent().globalCounter();
}
}
// FOOD Counter
class FoodCounterComponent extends CounterSuperComponent {
constructor() {
super(
{title: 'Food'}
);
}
}
FoodCounterComponent.register('FoodCounterComponent');
// BEER Counter
class BeerCounterComponent extends CounterSuperComponent {
constructor() {
super(
{title: 'Beer'}
);
}
}
BeerCounterComponent.register('BeerCounterComponent');
// ===================
// MOTHER-Component
// has access to to other components
// to regulate interactive behaviour
class MotherComponent extends BlazeComponent {
constructor() {
super();
log('constructor');
}
template() { return 'MotherComponentTemplate'; }
globalCounter() {
var self = this;
var beerCount = self.childComponents(BeerCounterComponent)[0].counter();
var foodCount = self.childComponents(FoodCounterComponent)[0].counter();
return beerCount + foodCount;
}
}
MotherComponent.register('MotherComponent');
HTML
<head>
<title>blaze components</title>
</head>
<body>
<p>Home</p>
{{> MotherComponent}}
</body>
<template name="MotherComponentTemplate">
<h1>MotherComponent</h1>
<p>Global Counter: {{globalCounter}}</p>
{{> FoodCounterComponent}}<!-- child components to MotherComponent -->
{{> BeerCounterComponent}}
</template>
<template name="CounterSuperComponentTemplate">
<h1>{{title}}-Counter</h1>
<button>click me to count a {{title}}</button>
<p>{{title}}-counts: {{counter}}</p>
<p>GLOBAL-count (fromMotherComponent): {{theGlobalCount}}</p>
</template>