These are chat archives for canjs/canjs

23rd
Nov 2016
Frank Lemanschik
@frank-dspeed
Nov 23 2016 07:14
@phillipskevin i think lazymaps are a core part of v3
but i think we call them simple map :)
Frank Lemanschik
@frank-dspeed
Nov 23 2016 07:21
@jeroencornelissen The braking change that your facing is leakScope v3 has it set to false you need to set it to true https://canjs.com/docs/can.Component.prototype.leakScope.html
Kevin Phillips
@phillipskevin
Nov 23 2016 13:38
@frank-dspeed LazyMap and can-simple-map aren't the same. SimpleMap doesn't meet the "lazy" part of LazyMap.
Frank Lemanschik
@frank-dspeed
Nov 23 2016 14:45
your 100% right but i am pritty sure i saw last weeks some getters and setters meeting that lazy part
Justin Meyer
@justinbmeyer
Nov 23 2016 15:16
@frank-dspeed DefineMap's initializers are lazy. And while it's not as lazy as lazy-map ... it's much faster than can.Map.
and I think it will have better performance than any LazyMap did
@web-mech are you using 3.0?
if you want a very fast property, use propName: "any"
Viktor Busko
@Lighttree
Nov 23 2016 15:18
Hi guys, I have a collection of users ~1000 items there. And I'm implementing filter for this collection by its fields and this logic will be a bit more complicated later. The problem is that even now this filter seems quite slow especially in IE11. I think this might be related to wrong using can.map or something like that. Maybe someone can have a look on this fiddle and help: https://jsfiddle.net/lighttree/L3rkts9p/3/
Justin Meyer
@justinbmeyer
Nov 23 2016 15:19
@Lighttree have you tried this with 2.3?
Viktor Busko
@Lighttree
Nov 23 2016 15:19
not yet
Justin Meyer
@justinbmeyer
Nov 23 2016 15:20
so, that should speed things up a bit ... of course going to DefineMap with 3.0 will do it even more
does it only get bad if filterTerms has multiple items?
b/c I'm seeing a double loop
Viktor Busko
@Lighttree
Nov 23 2016 15:22
I think the slowest moment actually when I remove search terms at all
Justin Meyer
@justinbmeyer
Nov 23 2016 15:22
also, are you expecting items to be added or removed dynamically to filteredParticipants ?
Viktor Busko
@Lighttree
Nov 23 2016 15:23
yes
Justin Meyer
@justinbmeyer
Nov 23 2016 15:23
from outside the filtering?
Viktor Busko
@Lighttree
Nov 23 2016 15:23
so I would like to type text in filter input and list should update on the fly
Justin Meyer
@justinbmeyer
Nov 23 2016 15:23
yeah
Frank Lemanschik
@frank-dspeed
Nov 23 2016 15:24
@justinbmeyer so we can call can define map already lazy map :) that was it :) i was 100% sure to see this lazy getter setters :D thx for pointing that out
Justin Meyer
@justinbmeyer
Nov 23 2016 15:26
@Lighttree I mean, do you expect to be dynamically inserting and removing items in your list from outside the filter
for example, another part of the page is creating these items
or you've got real-time setup
Viktor Busko
@Lighttree
Nov 23 2016 15:27
yes, not real-time, but there will be also a form that allows me to add new participants to this list. And items should have ability to remove themself from this list
Justin Meyer
@justinbmeyer
Nov 23 2016 15:27
does changing {{#each filteredParticipants}} to {{#filteredParticipants}}
speed things up?
Viktor Busko
@Lighttree
Nov 23 2016 15:28
let me check
Justin Meyer
@justinbmeyer
Nov 23 2016 15:28
also, can you tell me what the time difference is in between
filter: function(filterString) {
    var start = new Date();
            this.attr('filterString', filterString);
   console.log( new Date() - start );
        }
there in IE11
and also around the actual filtering
inside
filteredParticipants: {
                get: function(currentValue
Viktor Busko
@Lighttree
Nov 23 2016 15:35
ok it is 12ms for setting attribute and something like 3479 for actual filtering. When I continue typing it becomes faster (actual filtering), but if I clear field so term will be "undefined" filtering will take way more ~13511
Viktor Busko
@Lighttree
Nov 23 2016 15:47

b/c I'm seeing a double loop

even when I change this double loop to something simpler like:

filteredList = currentValue.filter(function(item) {
         return item.firstName.toLowerCase().startsWith(filterString.toLowerCase());
 });

these timings mostly the same, so it seems like complexity of filtrating is not bottleneck

Justin Meyer
@justinbmeyer
Nov 23 2016 15:48
(helping someone else right now, I'll be able to help later today)
my thought would be to change that to a simple for-loop that filters into a normal array
Viktor Busko
@Lighttree
Nov 23 2016 15:48
yeah sure, thank you
Justin Meyer
@justinbmeyer
Nov 23 2016 15:48
instead of a List
Jeroen Cornelissen
@jeroencornelissen
Nov 23 2016 16:01
@justinbmeyer I managed to get things working with our custom ajax header by doing ajax : $.ajax.
But would this be possible to do this on a canjs level, so we wouldn’t need jQuery.Ajax?
So something like can.ajaxSetup({…})?
I would prefer to have one file I can include that has our custom ajaxSetup and don’t worry about setting ajax : $.ajax for every model or ajax request.
Frank Lemanschik
@frank-dspeed
Nov 23 2016 16:11
@jeroencornelissen you should be also able to require a central configured $.ajax with your settings or require the settings via a js file
Frank Lemanschik
@frank-dspeed
Nov 23 2016 16:35
var $ = require('jquery')
var canAjax = function or object or what ever your like
module.exports(canAjax)
Justin Meyer
@justinbmeyer
Nov 23 2016 16:36
@jeroencornelissen usually, people build their own supermodel that sets things up however they want
can-util/ajax is designed to be stupidly simple ajax helper
I'm not sure I want to throw more complexity at it
you could also create your own behavior that would do this
that would replace can-connect/data/url/
@Lighttree I'm confused by that ... setting the attribute should take longer than the filtering because it should include the filtering
setting the property should cause filter to run immediately
and then update the dom
Justin Meyer
@justinbmeyer
Nov 23 2016 16:41
I'm trying to separate the filtering from the DOM update performance
Viktor Busko
@Lighttree
Nov 23 2016 16:46
@justinbmeyer yes, you are right, just added some text to consoles. setting the attribute takes longer
my mistake
Chasen Le Hara
@chasenlehara
Nov 23 2016 17:00
Hey everyone, check out our live stream on using CanJS 3 to build a digital and canvas analog clock at 10:30 AM Pacific Time (1.5 hours from now)! https://www.youtube.com/watch?v=4zIWIMDa490
Frank Lemanschik
@frank-dspeed
Nov 23 2016 18:03
ok will watch it :)
Sunil George
@georgesunil81
Nov 23 2016 19:29
Had a quick question regarding unbinding events in can.control
In my can.control, I have a method -
'#message-filter change': function(el, ev) {            
            this.renderWorkCenter();            
 },
I want to disable the change event from within another function like below -
'#reset-filter click': function(el, ev) { 
        can.unbind.call($('#message-filter'), 'change', '#message-filter change');
It does not work the way I have it above.
Any ideas?
Justin Meyer
@justinbmeyer
Nov 23 2016 19:33
Can you just set a value?
and check for that value in #message-filter change
'#message-filter change': function(el, ev) {            
        if(this.okToRender) {
            this.renderWorkCenter();            
        }
 },
'#reset-filter click': function(el, ev) { 
  this.okToRender = false;
Sunil George
@georgesunil81
Nov 23 2016 19:35
Thanks @justinbmeyer . I could do that. I was trying to temporary disable the change event, set a value and enable the change event again.
Sunil George
@georgesunil81
Nov 23 2016 19:40
Is there a way to temporarily disable '#message-filter change' and turn it on again?
Justin Meyer
@justinbmeyer
Nov 23 2016 19:41
not really
I think what I'm suggesting is going to be a lot easier
Sunil George
@georgesunil81
Nov 23 2016 19:42
Sure. I will be doing it that way. Solves the problem for me. Thanks Justin.