These are chat archives for canjs/canjs

17th
Sep 2018
Andrei Balmus
@abalmush
Sep 17 2018 07:49
@MarcGodard you can find a model of the component using can.viewModel - https://canjs.com/doc/can-view-model.html
Kevin Phillips
@phillipskevin
Sep 17 2018 13:51
@abalmush are you using steal somewhere in your code?
Andrei Balmus
@abalmush
Sep 17 2018 13:52
HI @phillipskevin nope, it comes from canjs package map/backup/backup
as per stack trace
if I creat component inside my test file no issues )
The only thing I do in my code is this: import ‘can/map/backup/backup’;
so I can backup my Map and restore it if needed
Kevin Phillips
@phillipskevin
Sep 17 2018 14:01
ok, I'll take a look
oh, just because all can packages are using steal syntax in 2.x
Andrei Balmus
@abalmush
Sep 17 2018 14:01
OK sure thank you. Btw this is old canjs 2.3
yeah
Kevin Phillips
@phillipskevin
Sep 17 2018 14:08
I'm not sure exactly how to configure Jest to work with this global variable
I'm sure someone has done it hough
Andrei Balmus
@abalmush
Sep 17 2018 14:11
Yeah, I will return back to this issue and try to resolve it some urgent stuff popped up and I have to postpone it.
Kevin Phillips
@phillipskevin
Sep 17 2018 14:11
ok
@MarcGodard you would do something like this
// parent-view-model.js
ViewModel: {
    sessionPromise: {
        default() {
            return Session.get({});
        }
    }
}
// child-view-model.js
ViewModel: {
    sessionPromise: "any",

    session: {
        get(lastSet, resolve) {
            if (this.sessionPromise) {
                this.sessionPromise.then(resolve);
            }
        }
    }
}
Kevin Phillips
@phillipskevin
Sep 17 2018 14:17
and then pass the sessionPromise from the parent to the child through a binding
Marc Godard
@MarcGodard
Sep 17 2018 18:30
@phillipskevin Thanks, thats what I was looking for
Kevin Phillips
@phillipskevin
Sep 17 2018 18:31
:thumbsup:
Andrei Balmus
@abalmush
Sep 17 2018 18:40
Hah, I completely misunderstood the question :) sorry