These are chat archives for canjs/canjs

21st
Apr 2016
Matthew Phillips
@matthewp
Apr 21 2016 02:06
ah yes, directories.lib is the answer, thanks @Bajix
Andrei Balmus
@abalmush
Apr 21 2016 07:43
wow, thank you @Bajix ! ididn’t know abut this option :D
mamamia it works :D
Matthew Phillips
@matthewp
Apr 21 2016 10:29
@Bajix @abalmush posted to the forums: http://forums.donejs.com/t/configuring-jspm-to-load-canjs/237
Mohamed Cherif Bouchelaghem
@cherifGsoul
Apr 21 2016 10:30
@matthewp morning you wake early :D
Andrei Balmus
@abalmush
Apr 21 2016 10:41
@matthewp great stuff thank you a lot!
Matthew Phillips
@matthewp
Apr 21 2016 11:37
@cherifGsoul I wake up early to work on fun stuff,
not to say my day job isn't fun
Julian
@pYr0x
Apr 21 2016 11:51
:D
and which fun stuff it is?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Apr 21 2016 12:54
@matthewp nice :+1:
Justin Meyer
@justinbmeyer
Apr 21 2016 14:45
@pYr0x yt?
Julian
@pYr0x
Apr 21 2016 14:54
yt?
Julian
@pYr0x
Apr 21 2016 15:41
@justinbmeyer what is yt?
Justin Meyer
@justinbmeyer
Apr 21 2016 15:42
yt = you there
a way to ask if someone is around
seems like you are :-)
anyway ... I wanted to help you w/ can-connect
Mohamed Cherif Bouchelaghem
@cherifGsoul
Apr 21 2016 15:44
@justinbmeyer me need to check this donejs/generator-donejs#119
:)
I dont see why the build fails in node V5
Justin Meyer
@justinbmeyer
Apr 21 2016 15:49
@cherifGsoul maybe @daffl or @matthewp can add you to appveyor
I can't seem to find how
Mohamed Cherif Bouchelaghem
@cherifGsoul
Apr 21 2016 15:50
ok thanks @justinbmeyer
@pYr0x do you want to talk about can-connect?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Apr 21 2016 15:51
ok thank you
Julian
@pYr0x
Apr 21 2016 16:03
@justinbmeyer i am on my way home
give me 30 minutes
if you want
Julian
@pYr0x
Apr 21 2016 16:29
@justinbmeyer i am now at home
do you want to talk
Sunil George
@georgesunil81
Apr 21 2016 18:18
@pYr0x I am trying to find more info on can-connect too, please let me know if you find some examples on how to use it. I want to see if I can get rid of SignalR in my project and use can-connect instead.
Julian
@pYr0x
Apr 21 2016 18:18
you can go to the forum
i posted some threads
and there a jsbins inside
you can look into that
Sunil George
@georgesunil81
Apr 21 2016 18:19
forum?
Sorry, so many forums.
Sunil George
@georgesunil81
Apr 21 2016 18:21
@pYr0x Thanks buddy. Those threads seem useful, I will go through them.
Thank you so much.
Julian
@pYr0x
Apr 21 2016 18:22
np
Sunil George
@georgesunil81
Apr 21 2016 18:24
@pYr0x quick question, I am trying to see if I can chain multiple model.findAll()
Is there any promise based chaining that I can do?
Julian
@pYr0x
Apr 21 2016 18:26
you mean model.findAll().findAll()?
Sunil George
@georgesunil81
Apr 21 2016 18:27
Can we do like that? Cool.
Julian
@pYr0x
Apr 21 2016 18:27
no
;)
Kevin Phillips
@phillipskevin
Apr 21 2016 18:27
what would that do?
Sunil George
@georgesunil81
Apr 21 2016 18:27
:)
So, something like model.findAll().then()
Kevin Phillips
@phillipskevin
Apr 21 2016 18:28
model.findAll()
    .then(function () {
        model.findAll();
    });
Sunil George
@georgesunil81
Apr 21 2016 18:28
Got it. thanks @phillipskevin
Thanks @pYr0x
Kevin Phillips
@phillipskevin
Apr 21 2016 18:28
I’m still not sure why you would want to do that
but you can
Guido Smeets
@gsmeets
Apr 21 2016 18:51
Maybe defining a bunch of getters depending on each other makes more sense
Or batching the fetch in one bigger model
Sunil George
@georgesunil81
Apr 21 2016 19:47
@pYr0x I have an array of objects called accounts that I am passing to stache. It shows up a Map, like "accounts: Map[2]", how would I refer to array elements within it?
I tried {{accounts0.accountname}} and it shows up as Object[object] in the view!?
Kevin Phillips
@phillipskevin
Apr 21 2016 19:48
{{#each accounts}} {{accountName}} {{/each}} ?
Sunil George
@georgesunil81
Apr 21 2016 19:49
Oh, let me try that.
Kevin Phillips
@phillipskevin
Apr 21 2016 19:49
sorry, screwed that up typing a couple times
Sunil George
@georgesunil81
Apr 21 2016 20:03
It worked for me. Thanks @phillipskevin
Kevin Phillips
@phillipskevin
Apr 21 2016 20:03
no problem
justthismorning
@justthismorning
Apr 21 2016 20:07

Is this possible?

Say I have two lists

var dogs=["Fido", "Rover"];
var cats=["Sassy", "Mittens"];

I have a component that calls pet-list

<can-import from="pets.component">
  <pet-list/>
</can-import>

And I have pet-list that loops through data

{{#pets}}
  <li>{{.}}</li>
{{/pets}}

I want to call the pet-list component twice, once with dogs as pets and once with cats as pets

If it's possible, how do I do it? I couldn't find anything in the documentation about setting the context in this way.

Kevin Phillips
@phillipskevin
Apr 21 2016 20:11
you would want to do something like <pet-list {pets}=“dogs” />
then a second one <pet-list {pets}=“cats” />
justthismorning
@justthismorning
Apr 21 2016 20:13
ah, thank you. I was looking in the wrong place
Kevin Phillips
@phillipskevin
Apr 21 2016 20:14
you’re welcome
Sunil George
@georgesunil81
Apr 21 2016 20:29
Hey, gitter is acting up on me. My messages seem to get repeated without my knowledge :)
Chris
@chrischrischris
Apr 21 2016 21:57
what is the recommended way to iterate through a subset of a list in a stache template? Using {{#each ...}} will iterate through all items in the list but I only want to display the first 5
Kevin Phillips
@phillipskevin
Apr 21 2016 22:07
I would probably create a derived property on the viewModel for just those items
then just {{#each}} over those
something like
var ViewModel = can.Map.extend({
  define: {
    allItems: {
      Type: can.List,
      Value: Array
    },
    firstFiveItems: {
      Type: can.List,
      get: function () {
        return this.attr('allItems').slice(0, 5)
      }
    }
  }
});
Chris
@chrischrischris
Apr 21 2016 22:27
ok, yeah that's what I ended up doing, thanks for reaffirming that that is the way to go
Kevin Phillips
@phillipskevin
Apr 21 2016 22:27
:thumbsup:
Chris
@chrischrischris
Apr 21 2016 22:29
is there much gained from using define vs just a plain attribute?
Kevin Phillips
@phillipskevin
Apr 21 2016 22:33
in this specific case, I’m not sure, but using define is definitely the way it is done more often
Chris
@chrischrischris
Apr 21 2016 22:33
ok good to know, guess I should start using that =)
Kevin Phillips
@phillipskevin
Apr 21 2016 22:34
it probably irons out some edge cases for you… like you won’t ever run into errors like can’t call function slice of undefined
because you specify the default value of allItems
Kevin Phillips
@phillipskevin
Apr 21 2016 22:40
there are probably other benefits I’m not thinking of
Chris
@chrischrischris
Apr 21 2016 22:43

I ran into an interesting issue today where using can.proxy inside of a list.each was setting this as undefined:

mylist.each(can.proxy(function (v,i) {...}, this));

interestingly using $.proxy works as expected ... have you seen this before? If not I can file a bug when I get some time.