Thanks @daveeel and @manuel that really helps.
My bad I thought for some crazy reason ViewModel was built on Angular2ās rendering and event model somehow.
Sounds like Iāll go with your React ViewModel implementation as a view handler.
And thanks for the offer of help Iāll probably pipe up with a curly one sometime
cheers
manuel
July 21, 2016, 5:29am
332
You may have gotten that idea because I usually describe ViewModel as āAngular without the boilerplate and ceremoniesā
1 Like
janmp
July 21, 2016, 8:45am
333
Viewmodel for React may actually let me give react another try.
But there is still the issue of using coffee-script with react (and Viewmodel is really so much nicer with coffee-script). CJSX works, but I havenāt found a linter that integrates with atom. I know you are into coffee-script. And hints on the web are somewhat sparse and mostly outdated. Any advice?
2 Likes
M4v3R
July 21, 2016, 1:24pm
334
@manuel Any idea when we can expect non-preview release of ViewModel for React? Iām a Blaze fan myself but seeing that even you probably wonāt consider Blaze for your next project makes me wanting to reconsider my choices
1 Like
aadams
July 21, 2016, 2:08pm
335
Is ViewModel for React ready to try out?
XTA
July 21, 2016, 2:49pm
336
manuel
July 21, 2016, 4:15pm
337
@M4v3R @aadams
I think itās ready to use but itās missing a few things ViewModel for Blaze has:
I will add those soon.
@janmp
I love CoffeeScript but I donāt miss it that much working with ViewModel (or ES6 for that matter).Take the following CJSX as an example:
Time
showTitle: ''
time: -> new Date()
render: ->
<h1 b="if: showTime, text: time" />
Letās be honest, that isnāt too far from the JSX version:
Time({
showTime: true,
time() {
return new Date();
},
render() {
<h1 b="if: showTime, text: time" />
}
})
aadams
July 22, 2016, 9:07pm
338
Thanks @manuel .
I have a ton of screens are are just forms (inputs/dates/radio/checkbox controls) with a submit button.
Do you know of any examples of using with forms using your tech?
For example, client side, reactive, validation on the form? Maybe even using your tech with Simple Schema?
Iām trying to move away from Autoform and am thinking of React these days, but wiring up reactive client side validation done right is a real pain.
manuel
July 22, 2016, 10:11pm
339
Iām away from my computer but I wanted to point you to some areas of the documentation so you can make a decision.
For what itās worth, Iāve never felt the need for something like auto forms and plenty of people started using both ViewModel and autoform at the same time and then dropped autoform because they felt they didnāt need it.
Check out the following:
https://viewmodel.org/react#AdvancedValidation
https://viewmodel.org/docs/misc#controls
The gist of it is that you can create your own input controls with all the validation they need.
2 Likes
Manuel, it seems that VM doesnāt support global helpers like currentUser or the ones created with registerHelper in bindings:
<template name="binding">
<input {{b "if: currentUser"}} type="checkbox" > checkbox
</template>
Doesnāt show the checkbox no matter if user logged in or not.
ps. Iām running VM 4.0.14 stillā¦
tomyo
October 15, 2016, 10:03pm
341
Hi, have you had success with VM and cjsx? Iām struggling with that now.
manuel
October 15, 2016, 11:09pm
342
I donāt think cjsx is possible with viewmodel-react because itās a babel plugin.
@avalanche1
How do you get the value of a global helper from JS?
janmp
October 16, 2016, 9:16am
343
No, have not looked into it. Sticking with Blaze on my current project.
What do you mean? currentUser
is a Meteor built-in Spacebars helper
manuel
October 17, 2016, 3:16pm
345
Yeah but to make {{b "if: currentUser"}}
work, I need to get the value from within ViewModel (plain JavaScript), not spacebars.
tomyo
October 17, 2016, 4:15pm
346
I think Iām doing the same then
Quick question, probably a simple answer.
How could I find items in the scope of regular Template.helpers? For example, how would I get data that regular Blaze would retrieve from Template.instance()?
Iām working with a package that is built for original blaze and is storing some data in helpers, I need to access them from my viewmodel??
manuel
November 28, 2016, 5:55pm
348
I honestly have no clue how you can call a template helper without creating a global one. How would you do it without VM?
So in the example in the OP, if we had:
Template.greeting.helpers({
firstName: function() {
return Template.instance().state.get("firstName");
}
});
And then we made
Template.greeting.viewmodel({
});
There would be no way to access firstName from the viewmodel?
manuel
November 28, 2016, 6:05pm
350
Wait, I thought you had no control over the helper. In that case you can just call the method directly:
Template.greeting.viewmodel({
firstName() {
return this.templateInstance.state.get("firstName");
},
anotherMethod() {
console.log( this.firstName() )
}
});