These are chat archives for canjs/canjs

8th
May 2018
Justin Meyer
@justinbmeyer
May 08 2018 03:09
@MarcGodard yeah. It would be good to have something documented that will last a long time
Viktor Busko
@Lighttree
May 08 2018 09:40
Guys, in DoneJS when you build component (in plugin) it pre-process stache to some render function. Is there place where I can see how it works ? I'm using Webpack and thinking about workflow that will allow me publish components to NPM in a way that won't require from host application some specific loader for stache.
Viktor Busko
@Lighttree
May 08 2018 11:16
Great, thanks
Justin Meyer
@justinbmeyer
May 08 2018 15:16
image.png
Viktor Busko
@Lighttree
May 08 2018 15:31
Can you send the same picture for Can3 ? :D
Just trying to get subset of items by Id for couple of hours...
Viktor Busko
@Lighttree
May 08 2018 15:40

Maybe someone knows.. If I have such fixture:

[
    {
        id: 1,
        lang: 'eng',
        properties: {
            key: 'value'
            ....
        }
    },
    {
        id: 2,
        lang: 'eng',
        properties: {
            key: 'value'
            ....
        }
    },
    ....
]

I'm creating model for this and use such map:

const I18n = DefineMap.extend({ seal: false }, {});

When I use

I18n.getList({})

It returns me data.

As soon as I change map to:

const I18n = DefineMap.extend({ seal: false }, {
    id: 'number',
    lang: 'string',
    properties: '*'
});

Same getList returns me empty object. I already checked that if I mention only id or lang or properties these fields will be removed from response.

And ideally I'm trying to do... is request subset like:

I18n.getList({
     id: [1, 3]
})

But this just doesn't work. Not sure what is correct approach.

Justin Meyer
@justinbmeyer
May 08 2018 15:49
hmmm, I'm not sure what's wrong, what you are showing should work
how are you wiring up your fixture?
can you post this in the forums?
Viktor Busko
@Lighttree
May 08 2018 15:50
image.png

can you post this in the forums?

Ok

Viktor Busko
@Lighttree
May 08 2018 15:56
wrong link :)
outdated I think
But yes, this is 3.latest
Justin Meyer
@justinbmeyer
May 08 2018 15:56
arg
there's with 3.0
Viktor Busko
@Lighttree
May 08 2018 15:59
hmm...
Justin Meyer
@justinbmeyer
May 08 2018 15:59
(if this helps you solve it and if you have time, please create a forum post ... folks have been giving us a hard time, saying that there's not enough searchable material ... so we are trying to create a index-able history of problems and solutions in the forums.)
Viktor Busko
@Lighttree
May 08 2018 16:00
ok, this works for getList without params, but what if I would like to get subset ?

(if this helps you solve it and if you have time, please create a forum post ... folks have been giving us a hard time, saying that there's not enough searchable material ... so we are trying to create a index-able history of problems and solutions in the forums.)

Sure, I just need to find out why it doesnt work in my code locally. :) I'm using it in tests, so maybe something related to this

Justin Meyer
@justinbmeyer
May 08 2018 16:19
what do you mean by subset? do you mean filter by lang?
well, if you are wanting real-time behavior, you need to make sure your lists and such are bound
Viktor Busko
@Lighttree
May 08 2018 16:44

what do you mean by subset? do you mean filter by lang?

No. In fixture I have N items, I would like to get items with ids: 1, 3, 5.

Basically to do this type of call: endpoint?Id[]=1pageIds[]=3pageIds[]=5 or ?pageId=1&pageId=3&pageId=5 (but afaik can is doing 1st option)
Nico R.
@nriesco
May 08 2018 17:26
Where is the best place to ask questions about routing? Donejs?
I have been using a workaround and I really need to understand how to solve it correctly
Nico R.
@nriesco
May 08 2018 17:39
I use canjs 3 and navigating using route usually breaks the app, specially when you go from /a/b/c to something that does not contain c like /a/b
Julian
@pYr0x
May 08 2018 18:19
anybody knows why this async getter always lastSetValue is true
if this.dataPromise resolved the 0 gets set. in the stache file 0 is shown
Julian
@pYr0x
May 08 2018 18:27
if the dataPromise changed the promise gets resolved again and resolve(0) is catched again. but at this time, lastSetValue is not false it is true
image.png
Justin Meyer
@justinbmeyer
May 08 2018 20:10
@pYr0x didn't really read it .. but the lastSetValue is the LAST SET VALUE ... not the last resolved value
could that be it?
@Lighttree canjs 5.0 handles that sort of filtering
this sort of filtering doesn't work in 3.0's can-fixture
Julian
@pYr0x
May 08 2018 20:20
@justinbmeyer i really makes a difference between last SET value and last RESOLVED value?
Justin Meyer
@justinbmeyer
May 08 2018 20:21
there is a difference between lastSet and resolved
think of lastSet as what flows in
and resolved as what flows out
when you do map.prop = VALUE, that's updating lastSet
that's the ONLY way to update lastSet
resolve is used to update what someone sees as a result of reading the value
Julian
@pYr0x
May 08 2018 20:22
ok ... never know that...
:D
Justin Meyer
@justinbmeyer
May 08 2018 20:23
yeah, it's a really common source of confusion
Julian
@pYr0x
May 08 2018 20:23
the docs said that, but not that clear way ;) The value last set by instance.propertyName = value.
Justin Meyer
@justinbmeyer
May 08 2018 20:23
people think that lastSet is the last "exported" or resolved value
Julian
@pYr0x
May 08 2018 20:23
yeah.
me too
Justin Meyer
@justinbmeyer
May 08 2018 20:23
if you have suggestions on how to clear up the docs, that would be great!
Julian
@pYr0x
May 08 2018 20:24
i will think of it
Justin Meyer
@justinbmeyer
May 08 2018 20:24
but yeah, the "math" sort of requires lastSet from being independent from resolve
Julian
@pYr0x
May 08 2018 20:26
but the docs said: resolve {function(value)|undefined}: Updates the value of the property.
thats not true it will not update the properties value
not in that way people think of it
Justin Meyer
@justinbmeyer
May 08 2018 20:26
well, it depends on what you think of as "value"
if you think of value as what you read
map.prop -> VALUE
Julian
@pYr0x
May 08 2018 20:27
i think your explaination of: think of lastSet as what flows in
and resolved as what flows out
Justin Meyer
@justinbmeyer
May 08 2018 20:27
then it is updating the read value
Julian
@pYr0x
May 08 2018 20:27
is greate
Justin Meyer
@justinbmeyer
May 08 2018 20:27
👍
Julian
@pYr0x
May 08 2018 20:27
thank you for clarification :D
Justin Meyer
@justinbmeyer
May 08 2018 20:28
@/all a simple example of <can-slot> / <can-template>
Mohamed Cherif Bouchelaghem
@cherifGsoul
May 08 2018 21:38
@justinbmeyer thank you!
Justin Meyer
@justinbmeyer
May 08 2018 21:39
If you like that, check this out: https://canjs.github.io/next/doc/api.html
Mohamed Cherif Bouchelaghem
@cherifGsoul
May 08 2018 21:40
great!
I worked with <can-slot>/<can-template> for resuable components
Julian
@pYr0x
May 08 2018 22:00
:+1: i would like to work with the new rest API