dalgard / meteor-viewmodel

Minimalist VM for Meteor
24 stars 2 forks source link

Can't access ViewModel.addBinding from package #6

Closed zimt28 closed 8 years ago

zimt28 commented 8 years ago

I structure all my code in packages. I have a base-ui package, which is used by all other packages and implys dalgard:viewmodel@0.5.9. Everything seems to work, the only thing that doesn't is adding new bindings:

Uncaught TypeError: ViewModel.addBinding is not a function

dalgard commented 8 years ago

I think it depends on where you call it in your code, whether it has become present yet.

If you call ViewModel.addBinding inside a hook of any kind, it will be present, because the hook won't be run until after Meteor is fully loaded, incl. all implied packages.

If you call it in some top-level package code, it may not be present if you only imply'ed dalgard:viewmodel. Instead, you can use the package and be sure it will get injected properly.

P.S. It's great that you're using packages to organize your code :+1:

zimt28 commented 8 years ago

The solution is quite simple: I can't call ViewModel.addBinding because ViewModel is a reference to manuel's viewmodel :)

dalgard commented 8 years ago

Oh, good. Feel free to create more issues in the future.