Closed arggh closed 7 years ago
Check out this thread https://viewmodel.org/help/MiqtTm4J5yKDMZGcK it might give you an idea.
On May 28, 2017 6:58 AM, "arggh" notifications@github.com wrote:
Closed #284 https://github.com/ManuelDeLeon/viewmodel/issues/284.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/284#event-1100167048, or mute the thread https://github.com/notifications/unsubscribe-auth/AED31ovIBuK4mYBGIH9_K4ZZ9-OmccAgks5r-W9dgaJpZM4Lwegw .
Thanks for the link.
I wonder, what if, instead of writing this same helper over and over again in all my ViewModels...
byRef(prop) {
return () => this[prop];
}
...it could be part of every ViewModel out of the box?
Writing referencing functions to props being passed down the component chain, which is quite often if one tries to embrace the component oriented approach, sounds a lot like something ViewModel could alleviate in Blaze.
Though, I mostly have found myself passing down more complex stuff wrapped in objects anyway, not just VM props, like so:
{{> component componentArgs }}
// VM
componentArgs() {
return {
someAttr: true,
someRef: this.enabled,
options: importedStuff,
onChange() {
...
}
}
How these scenarios should ideally be dealed with... now that was originally hard to find in both ViewModel & Blaze's docs.
I added https://viewmodel.org/docs/misc#usingcontrols
In the end I used vmRef
instead of byRef
because I didn't want people scratching their heads wondering where that byRef
comes from. At least with vmRef
there's a clue.
Thanks for the help.
That was fast 👍 I agree, vmRef is better.
I've been using Semantic-UI in a project, but now would like to get rid of it entirely. This brings me to wonder, what would be the ideal ViewModel-way of building a dynamic and reusable modal- or a popup-component?
It's cumbersome enough using Blaze, and I'm having a hard time thinking of an elegant way to build such component with ViewModel and I'm not sure, if VM bring anything valuable to the table in this case?
Any guidance would be greatly appreciated!