Skip to content

Loading…

Compose.from #1

Open
dvv opened this Issue · 2 comments

2 participants

@dvv

A google console tour:

var p = C.create({foo: 'bar'}, {m1: function(){return 'IAMM1'}});
undefined
var u = C.create(p, {m2: function(){return 'IAMM2'}, foo:'baz'});
undefined
function PFacet(model){var f={};['m1','m2'].forEach(function(m){f[m]=C.from(model,m).bind(model);});return f;}
undefined
PFacet(u).m1()

compose.js:117 Object Error: Decorator not applied

PFacet(u).m2()

compose.js:117 Object Error: Decorator not applied

p.m1()
"IAMM1"
p.m2()
TypeError: Object #<an Object> has no method 'm2'
u.m2()
"IAMM2"
u.m1()
"IAMM1"

What I did wrong?

TIA,
--Vladimir

@kriszyp
Owner

If you bind() a decorator, it returns a function which is no longer a decorator, because a decorator is identified as a decorator by it's "install" property. I think maybe you want to do this instead:
C.from(model,m.bind(model))

@dvv

Seems one can't Compose.from() a non-aspected-previously method. I see nothing related to .install in Compose.from() code...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.