dalgard / meteor-viewmodel

Minimalist VM for Meteor
24 stars 2 forks source link

Converting from manuel:viewmodel #4

Closed zimt28 closed 8 years ago

zimt28 commented 8 years ago

dalgard:viewmodel and manuel:viewmodel both use the same Template.$.viewmodel syntax; so I can't have both in my app. But I'd like to move to your package step by step. How could I do that?

dalgard commented 8 years ago

Hmm, good point. I'll think about a solution.

I chose to use the same name as Manuel, because the name really makes sense. But it's kind of inconvenient in this situation.

dalgard commented 8 years ago

Do you have any preferences as to the naming of the new ViewModel class and viewmodel hook during the migration?

Ideally, the name should be able to convey to new developers what is going on.

ViewModel2 looks a bit too much like it's the next major version of the same library. NewViewModel doesn't really say anything. Maybe DalgardViewModel and dalgardViewmodel would be the least ambiguous choice...

dalgard commented 8 years ago

I finally arrived at the simplest possible solution and will be releasing a new version shortly, with the necessary steps described in the docs.

The steps are:

  1. Make sure dalgard:viewmodel is included before any package that exports a ViewModel and/or assigns something to Blaze.Template.prototype.viewmodel.
  2. Reassign the relevant stuff to whichever names you like.

For example:

// E.g. /client/lib/dalgard-viewmodel.js
DalgardViewModel = Package["dalgard:viewmodel"].ViewModel;
Blaze.Template.prototype.dalgardViewmodel = DalgardViewModel.viewmodelHook;
zimt28 commented 8 years ago

Great, thanks! I'll just try that! The name I'd use here is just vm, but it's a good solution to allow any!

dalgard commented 8 years ago

Whatever rocks your boat :) Kindly close the issue, once you've ascertained yourself that things are in order.

zimt28 commented 8 years ago

Works fine :)

dalgard commented 8 years ago

Please note that in the next version ViewModel.referenceName is changed to ViewModel.referenceKey. Thanks.