These are chat archives for canjs/canjs

1st
Dec 2016
Frank Lemanschik
@frank-dspeed
Dec 01 2016 12:54
Chasen Le Hara i think you need to use simply leakScope
@chasenlehara you can define the promis and then leak it to the component
only remember 3+ has default leakScope false
Kevin Phillips
@phillipskevin
Dec 01 2016 14:41
Can you show how that would work, @frank-dspeed? I’m not sure I understand.
Frank Lemanschik
@frank-dspeed
Dec 01 2016 14:48
kevin i could if i would get a more complet example from Chasen but in general there are 2 ways to solve that
frist easy understand able way is to do
<can-import from="components/my_tabs"/>
<can-import from="helpers/prettyDate"/>
<my-tabs>
  <my-panel title="{{prettyDate start}}">...</my-panel>
  <my-panel title="{{prettyDate end}}">...</my-panel>
</my-tabs>
in this example we use a leaked promis from the model of the helper
so we can inside our my-tabs wait for the resolved promis of prettyDate
Kevin Phillips
@phillipskevin
Dec 01 2016 14:52
I think he’s talking about the promise that can-import provides
the promise of the actual import
Frank Lemanschik
@frank-dspeed
Dec 01 2016 14:53
i think can import don't provides a promis :D
but let me look
Kevin Phillips
@phillipskevin
Dec 01 2016 14:53
the scope is a promise
Frank Lemanschik
@frank-dspeed
Dec 01 2016 14:53
what exactly do you define as scope in can-import?
Kevin Phillips
@phillipskevin
Dec 01 2016 14:54
<can-import from="components/my_tabs”>
  {{! this scope here is a promise}}
</can-import>
Frank Lemanschik
@frank-dspeed
Dec 01 2016 14:54
what should the name of it be i am wondering how that is accesible but anyway
Kevin Phillips
@phillipskevin
Dec 01 2016 14:55
yeah, I’m not sure it is
Frank Lemanschik
@frank-dspeed
Dec 01 2016 14:55
the name is not clear for me for that promis
and we don't got a can-import array or object that holds the imported stuff
Kevin Phillips
@phillipskevin
Dec 01 2016 14:55
with static imports (when you use /> on can-import), you can export the value of the promise
like <can-import from="app/person" {^value}="*person" />
that {^value} is the value the promise resolves
Frank Lemanschik
@frank-dspeed
Dec 01 2016 14:56
then its as simple as binding that value to the current view
and then look for that
Kevin Phillips
@phillipskevin
Dec 01 2016 14:56
he wants the actual promise though
not the value the promise resolves to
Frank Lemanschik
@frank-dspeed
Dec 01 2016 14:56
then he needs to create a promis on the Current View Model
and wait there for the result of the promis
Kevin Phillips
@phillipskevin
Dec 01 2016 14:57
yeah, there are other ways to do it manually
Frank Lemanschik
@frank-dspeed
Dec 01 2016 14:57
as can-import is not a global object where what we can access to see whats importet
i don't think there is a other way then do it manualy on run time if needed
Kevin Phillips
@phillipskevin
Dec 01 2016 14:58
with can-import I think the only way is inside the content of the can-import tag
<can-import from="components/example”>
    <other-component {import-did-resolve}=“isResolved" />
</can-import/>
Frank Lemanschik
@frank-dspeed
Dec 01 2016 14:58
other ways i do such stuff is always simply use the promis in the stache
  {{#if yourPromise.isResolved}}
  {{#each yourPromise.value}}
    your results
  {{/else}}
    no results
  {{/each}}
  {{/if}}
that are the only access points that i know
but it could be a interristing future :)
Maybe you or me should create a Proposal to export a global can-import object that has references to the promises
Kevin Phillips
@phillipskevin
Dec 01 2016 15:01
I’d have to get a better understanding of why it’s useful
Frank Lemanschik
@frank-dspeed
Dec 01 2016 15:01
its usefull on larger application stacks where you use a lot of cross depending plugins
then you need to know whats there whats not but i aggree you never need to check for the plugin via the can import promis
you can simply look if the export is there or not
like waiting for jquery loaded
but i like in general the idea to view via a object what gets loaded and what the status is for control flow
Kevin Phillips
@phillipskevin
Dec 01 2016 15:05
I could see wanting something like <can-import from="app/person" {^this}="*personPromise" />
Frank Lemanschik
@frank-dspeed
Dec 01 2016 15:05
also maybe steal already solves a lot of such situations via simply loading in the right order :)
Kevin Phillips
@phillipskevin
Dec 01 2016 15:05
where
{^this} would export the promise
and
{^value} would export the promise’s value
Frank Lemanschik
@frank-dspeed
Dec 01 2016 15:05
ya with can import the only problem i see is the name of the promis :D
ah i understand
ya thats also good
solving it on the can-import module and make a option to export the promis or value
good idea
Kevin Phillips
@phillipskevin
Dec 01 2016 15:07
but I’d have to do some experiments… I thought with static imports like that, the promise would always be resolved/rejected by the time the view is rendered
Frank Lemanschik
@frank-dspeed
Dec 01 2016 15:07
that would also enable to load alternate when it errors to lead
load
Kevin Phillips
@phillipskevin
Dec 01 2016 15:07
so I don’t know what you would use that promise for
Frank Lemanschik
@frank-dspeed
Dec 01 2016 15:07
good question the only thing you can do with it is look if its resolved :D or modify it
to have a diffrent result then expected
like conditional overwrites
i my self would use it simply to have a array of all promises of all helpers
to look if all loaded right :D
so it would be a easy way to get total application state
but i could also solve that manual via simply waiting for a return value of the plugin
Kevin Phillips
@phillipskevin
Dec 01 2016 15:10
yeah
I would normally just look at the value
Frank Lemanschik
@frank-dspeed
Dec 01 2016 15:12
ya we need to wait for @chasenlehara to tell whats the reason for exporting the promis but when it gives a reason then we should use your idea via implamenting the syntax for where
{^this} would export the promise
and
{^value} would export the promise’s value
also a Idea about this is to simply use can-import also in the other component :)
we can import as often as we like normaly
Frank Lemanschik
@frank-dspeed
Dec 01 2016 15:18
Oh Hell wait i have a 100% needed Case where we need that!!!!
What if can-import imports something realy big like a 100mb JSON File
then we sure never whant to do that request again in our application
so we need to give the promis to all sub components
so they know when this data is there like big map data or that
its importent for Progessiv Apps to load Instant even if this 100mb are not processed
i see a big speed gain there when a application handels bigger data directly without a query server
or if processing big query results
or even slow querys we can can-import once export ^this and bind that and give that to all other components
so each component can load and wait for resolving of a single promis without syntax changes
else more manual javascript coding is needed to address that and as its already on the agenda via primis.isResolved in the stache templates this is a missing part
Kevin Phillips
@phillipskevin
Dec 01 2016 15:30
but like I was saying, I think if you use a static import (with the />) loading that file would block your view from rendering
maybe I’m wrong
I haven’t tested it
Frank Lemanschik
@frank-dspeed
Dec 01 2016 15:31
hmmm
ya its complex
because you can also do
<can-import from="components/tabs">
    {{#if isResolved}}
        <tabs-widget />
    {{/if}}
</can-import>
so we can simple do what ever is to be done inside the loading tag of the import