Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 10:50
    chasenlehara opened #5462
  • 10:48

    chasenlehara on chasenlehara-patch-1

    Upgrade to can-queues@1.3.2 (compare)

  • 10:41

    chasenlehara on can-simple-dom-1.7.1

    (compare)

  • 10:41
    chasenlehara closed #5458
  • 10:40

    chasenlehara on can-stache-bindings-5.0.4

    (compare)

  • 10:40
    chasenlehara closed #5455
  • 10:40

    chasenlehara on can-stache-5.1.0

    (compare)

  • 10:40
    chasenlehara closed #5453
  • 10:40

    chasenlehara on can-map-4.3.12

    (compare)

  • 10:40
    chasenlehara closed #5452
  • 10:40

    chasenlehara on can-super-model-2.0.0

    (compare)

  • 10:40
    chasenlehara closed #5449
  • 10:40

    chasenlehara on can-define-rest-model-2.0.0

    (compare)

  • 10:40
    chasenlehara closed #5448
  • 10:39

    chasenlehara on can-define-realtime-rest-model-2.0.0

    (compare)

  • 10:39
    chasenlehara closed #5447
  • 10:39

    chasenlehara on can-connect-ndjson-2.0.0

    (compare)

  • 10:39
    chasenlehara closed #5446
  • 10:39

    chasenlehara on can-observable-mixin-1.0.7

    (compare)

  • 10:39
    chasenlehara closed #5444
Kevin Phillips
@phillipskevin
Christopher Oliphant
@RALifeCoach
yes - nested properties are causing the problem
Julian
@pYr0x
@phillipskevin yep, lazymap extends can.map
@RALifeCoach this stache isnt very short
and the test also
Christopher Oliphant
@RALifeCoach
Sorry - I can pare it down
Julian
@pYr0x
why?
this code isnt a testable code...
Christopher Oliphant
@RALifeCoach
it is much shorter now
Julian
@pYr0x
so we need the component?
can you remove that
Christopher Oliphant
@RALifeCoach
Better?
Julian
@pYr0x
didnt see any changes?
still a component
Christopher Oliphant
@RALifeCoach
yes there is still a component
how’s how my code works
Julian
@pYr0x
can you remove that too
Christopher Oliphant
@RALifeCoach
When I removed the component it stopped crashing
Julian
@pYr0x
;)
good to know
so the problem is not lazymap
it is the component?
Christopher Oliphant
@RALifeCoach
the line of code that is throwing the exception is in lazy map
Julian
@pYr0x
yes.. but the problem can come from other code
Kevin Phillips
@phillipskevin
the component probably causes lazyMap to set up the binding
the component binds, and lazymap tries to initialize the data
Christopher Oliphant
@RALifeCoach
it has to do with observables - and the component is the one telling lazy map to create the observable. If I knew the canJS code better, I could probably re-create without the component.
Kevin Phillips
@phillipskevin
just do theMap.bind(‘whatever.data.that.fails’, function() { … })
to bind to the map manually
Christopher Oliphant
@RALifeCoach
that didn’t crash either
At this point, the code is as small as I can make it and still have it crash. The bug may be in lazy map, it may be in component, it may be somewhere else altogether.
here is the latest - I will also post the link in the issue
Kevin Phillips
@phillipskevin
@RALifeCoach so your performace is better now using LazyMap?
Christopher Oliphant
@RALifeCoach
I am working through the changes now and I will keep you posted
the update is now down to 1 second
I was really hoping to have it lower
in the .6-.8 range
Christopher Oliphant
@RALifeCoach
            var template = can.stache('<player-row id="player-row-{{pid}}" {pid}="pid" {parent}="parent"></player-row>');
            var fragment = template({
                pid: this.pid,
                parent: this
            });
the player-row component has a viewModel and in the viewModel there is a set on pid. However, the set isn’t getting called. Instead the component starts trying to fill out the fragment from it’s stache view.
Thomas Sieverding
@Bajix

@RALifeCoach @pYr0x

5) Use computes like a mad man. The goal is to lower unnecessary change events. For example, the isAdmin getter I described above is actually really performant, as now I can bind to it elsewhere, and something like changing users or logging in that would trigger isAdmin to be re-computed wouldn’t trigger other computes that are dependent on isAdmin from re-computing if isAdmin doesn’t change

 isAdmin: {
  get: function() {
    var profile = this.attr('profile');

    if (profile) {
      return profile.attr('tier') === config.tiers.indexOf('admin');
    }

    return false
  }
}

Changing profile / tier would recompute this. But if the value hasn't changed, computes dependent on this wouldn't recompute

ok.. and what about the point 5) bajix said?

Computes cache if they're bound, and then re-compute whenever an observable they've bound to changes. Only if the re-computed value is different will it then emit a change event. So the general technique is to utilize computes for intermediate values, such that more expensive, poorly-cacheable computes would be re-computed less frequently. This is especially true for Component helpers, as new Document Fragments that would otherwise be identical still need to be re-rendered.

There's no need to shy away from components within loops either if that means that you're better able to accomplish the above. Using an extra component wins out if it reduces unnecessary DOM manipulation.

For example, the Chat app I work on uses a message component when iterating user messages. Consecutive messages from the same author are grouped, and messages can come out of order; using a component to manage state based off of the prev/next message means my section helpers trigger O(n^3) times less often.

TLDR; Make cache-able computes. Use cache-able intermediates. Win at helpers. Win at computed objects.

Guido Smeets
@gsmeets
Hmm, there was an issue on github that discussed all the details for the 2.3 binding syntax, I can't find it anymore. Anyone happen to know which issue I'm referring to?
Mohamed Cherif Bouchelaghem
@cherifGsoul
@gsmeets did you do a filter for closed issues?
Guido Smeets
@gsmeets
@cherifGsoul yeah I did, just can't recall what it was named
I, got it #1700
Mohamed Cherif Bouchelaghem
@cherifGsoul
ok I tought it was opened by you ;)
Dovid Bleier
@dbleier
when a compute changes value, do only other define getters that use that compute rerun, or do map methods using the compute also rerun?