I’ve written a new viewmodel package for Meteor, inspired by manuel:viewmodel
and nikhizzle:session-bind
:
The point of using viewmodels in Meteor is to reduce the amount of code and make things more declarative. In some cases, pretty radically so.
My reason for writing a new package was that I felt things could be simplified quite a bit, while preserving the full power of the VM pattern. I believe I’ve accomplished my goal, but at the same time have added some useful features.
I’m working a bit closer with Blaze, compared to manuel:viewmodel
, in the way that everything is registered as helpers, and instead of having bindings such as class
and text
, you are encouraged to use helpers in the standard way.
Importantly, bind declarations work inside #if
and #each
helpers.
Among other features are:
- Persist viewmodel state across hot code push
- Optionally persist viewmodel state across navigation (new route and then back button)
- Optionally keep instances of the same viewmodel in sync on the page
- Very easy and declarative bindings API
- Automatic creation of undeclared viewmodels and properties
- And more, as they say…
This package showed out to be a great fit for ES2015, by the way, which I highly recommend using.
Check it out and give me your opinions