These are chat archives for canjs/canjs

16th
Jul 2015
Patrick Clancy
@patrickclancy
Jul 16 2015 14:33

Is it possible to pass (via an attribute) in a deferred object to a component? I can pass a plain object, so my assumption was this would work. But it doesn’t…

<test-component2 my-dfd="{dfd}"></test-component2>

http://jsbin.com/fukocu/edit?html,js,output

dylanrtt
@dylanrtt
Jul 16 2015 14:43
@patrickclancy wrapping the deferred in a promise (e.g., Promise.resolve(defObj)) works but you won't be able to resolve it from the child component if that's your use case
Patrick Clancy
@patrickclancy
Jul 16 2015 14:51
@dylanrtt interesting… wrapping it in another then’able’ object works. Still feels strange. But that is a solution.
thank you
Justin Meyer
@justinbmeyer
Jul 16 2015 14:59
https://github.com/bitovi/canjs/issues/1781#issuecomment-121981031 Thoughts on how to make validations work across components.
Justin Meyer
@justinbmeyer
Jul 16 2015 15:05
@DipeshRaichana let me know if you want to talk through those questions.
Justin Meyer
@justinbmeyer
Jul 16 2015 17:15
Here's some docs on how you can migrate away from can.Model to can-connect: http://connect.canjs.com/doc/can-connect%7Ccan%7Cmodel.html
Patrick Clancy
@patrickclancy
Jul 16 2015 18:38
@dylanrtt Turns out a promise won’t work for me. I’ll see if I can find why passing a deferred fails.
Justin Meyer
@justinbmeyer
Jul 16 2015 20:31
@patrickclancy @dylanrtt if passing a promise or deferred doesn't work, can you create an issue?
it certainly seems like a bug
oh, I know what the problem is
this isn't a bug
but an API thing we should fix for 3.0
the problem is that the template isn't rendered until all promises were resolved
this is a hold-over from early JMVC days
before live-binding
Justin Meyer
@justinbmeyer
Jul 16 2015 20:36
it works if you do it this way: