meteor-collection-behaviours icon indicating copy to clipboard operation
meteor-collection-behaviours copied to clipboard

Behavious do not get attached to Collections automatically

Open svub opened this issue 10 years ago • 1 comments

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)

svub avatar Dec 18 '14 12:12 svub

Thanks for pointing that out, I didn't know why it wasn't working!

taromero avatar Feb 02 '15 22:02 taromero