These are chat archives for canjs/canjs

27th
Jul 2018
Stef
@sronsiek
Jul 27 2018 07:16
@justinbmeyer Thanks for the suggestion on helpers inheritance - in the end I opted for a different solution - I created a file with registeredHelper() calls to my helpers, imported once by the app - this seems to make them avail globally, avoiding the need for inheritance & everything is in one place!
Matthew Phillips
@matthewp
Jul 27 2018 11:27
@ivospinheiro that's so cool that it shows where the error happens like that
My guess is that the Colors thing is sealed?
If so it probably can't be used with can list..
Is it possible to debug with this tool?
If so that could help to find out more...
Justin Meyer
@justinbmeyer
Jul 27 2018 14:13
@ivospinheiro it seems can-list is trying to convert that into an observable
is this something new as you are upgrading?
Ivo Pinheiro
@ivospinheiro
Jul 27 2018 14:13
yes
and it works fine with can-list@4.1.0
Justin Meyer
@justinbmeyer
Jul 27 2018 14:14
@roemhildtg can you create a sample repo with this problem?
@ivospinheiro can you create an issue, and I'll see if I can look at it today.
Yes I will do that
Thanks @justinbmeyer
Ivo Pinheiro
@ivospinheiro
Jul 27 2018 15:03
Hi @justinbmeyer
The issue has been created canjs/can-list#82
It seems to be related with the fact that the Array used to create the CanList is frozen
Viktor Busko
@Lighttree
Jul 27 2018 15:46

Guys, is it possible to debounce defineList mutations ? (CanJS3)
I think that streams can help here and trying to do something like this, but it just doesn't work :(

this.translationKeys = new DefineList([]);
this.translationKeysChangeCountStream = canStream.toStream(this.translationKeys, 'length');
this.debounced = this.translationKeysChangeCountStream.debounce(250);
this.debounced.log();

I'm doing some network calls based on this list mutation and would like to decrease amount of network calls.

or maybe can-event/batch better here, i'll try
Ivo Pinheiro
@ivospinheiro
Jul 27 2018 16:43
Hi!
I'm having an issue when serializing a CanMap having properties set with CanMaps with its own serialize method.
Here is a sample code:
var MyMap = can.Map.extend({
  define: {
    prop: {
     type: "string"
    }
  },
  serialize(){
    return "Serialized: " + this.attr("prop1");
  }
});

var map = new can.Map({
  entry1: new MyMap({prop1: "abc"})
});

console.log(map.serialize());

I was expecting the result to be:

{
  entry1: "Serialized: abc"
}

But the result is:

{
  entry1:{ prop1: "abc"}
}
Here is an example demonstrating this issue:
https://jsbin.com/lawiyotoga/1/edit?html,js,console