meteor-collection-behaviours
meteor-collection-behaviours copied to clipboard
Behavious do not get attached to Collections automatically
I'm very happy that you continue the collection behavours package. I used it via mrt before and switched to Meteor 1 now. I noticed one "strange" behaviour, or is it intended?
I wrote a behaviour called "owned" and want to attach it to a collection called "Activities". Here some testing code I wrote (using CoffeeScript):
log CollectionBehaviours
log Activities.owned?
CollectionBehaviours.extendCollectionInstance Activities
log Activities.owned?
Activities.owned()
(FYI, log
is just a logger to console; ...?
is CoffeeScript's way of checking for a var's existance, i.e. owned?
equals typeof owned !== "undefined" && owned !== null
in JS)
The output is:
Object {defineBehaviour: function, extendCollectionInstance: function}
false
true
I.e. I need to call CollectionBehaviours.extendCollectionInstance Activities
explicitly so that I can call owned()
on the collection. Intentionally? (the mrt version did that automatically somehow)
Thanks for pointing that out, I didn't know why it wasn't working!