These are chat archives for canjs/canjs

12th
Nov 2015
Mihai Fantana
@fantanamihai
Nov 12 2015 13:54
hi guys. canjs 2.3.1.Is there a policy when user events are triggered and catched with Control.on(..)?
Mihai Fantana
@fantanamihai
Nov 12 2015 13:59
I noticed if for example, I bind a user event called 'justLettersNumbersOr_', when later in the code I call this.on() - to rebind events, the user event is ignored
hopefully more clear:
can.Control.extend('Example', {}, {
    init: function() {
       this.on(this.element, 'justLettersNumbersOr_', 'justLettersNumbersOr_'); //catch justLettersNumbersOr_
       this.on(); //justLettersNumbersOr_ will never be catched
    },

    'justLettersNumbersOr_': function() {
    }
}
Stan Carrico
@shcarrico
Nov 12 2015 20:23
can 2.3.1 question.. I notice when i call .serialize() on a map instance, there is a new property hanging around called %root
it's polluting my route at the moment.. is there something new I need to do, or is this a bug I should open or ?
I added a define block for it to set serialize: false, but that feels hacky / might have side effects ?
Matthew Phillips
@matthewp
Nov 12 2015 20:30
That would be on a View Model I think, right?
a component viewmodel
oh, maybe not
well, i'm not sure
Julia Allyce
@julia-allyce
Nov 12 2015 20:35
when does can-connect make an API call vs fetch from local storage? Does it keep a copy in memory of models?
Justin Meyer
@justinbmeyer
Nov 12 2015 20:44
@julia-allyce it depends on what behaviors are added
if you are using superMap, which pulls in the fall-through-cache behavior
it always makes an API call
but, if there's data in localstorage, it will respond with that initially
and then, in the background, update it with the data from the service layer
that last link shows a video that explains
Stan Carrico
@shcarrico
Nov 12 2015 20:47
@matthewp yes. I'm putting a viewmodel into a component and then providing it to can.route
Julia Allyce
@julia-allyce
Nov 12 2015 20:49
so if I getList and it imediately resolves its promise with the cache(if it exists), it will then make a fetch to the API in the background and resolve the same promise again?
@justinbmeyer ^
Justin Meyer
@justinbmeyer
Nov 12 2015 20:49
it doesn't resolve the same promise again
it updates the data
(this works great b/c canjs has observables)
Julia Allyce
@julia-allyce
Nov 12 2015 20:50
yea
Justin Meyer
@justinbmeyer
Nov 12 2015 20:50
in react-land
you'll somehow have to get setState called
there's an updateList hook
which is called when a list is being updated
changed to a better link
Julia Allyce
@julia-allyce
Nov 12 2015 20:53
the docs need some love
but anyway
I want to save/destroy a model, and then be able to update my list of models without having to make an API call
Justin Meyer
@justinbmeyer
Nov 12 2015 20:55
what do you mean by make an API call?
Julia Allyce
@julia-allyce
Nov 12 2015 20:55
i just want the cached data, because presumably the list has been updated on save
Matthew Phillips
@matthewp
Nov 12 2015 20:58
@shcarrico yes, that's a bug then, it should be serialize: false
Stan Carrico
@shcarrico
Nov 12 2015 21:00
@matthewp should I open an issue? am not sure it does it w/o being added into a component first.. i assume not?
Matthew Phillips
@matthewp
Nov 12 2015 21:01
It's only added for component view models
Stan Carrico
@shcarrico
Nov 12 2015 21:02
ok cool. perhaps i'm doing a non standard thing by re-using one of those in a route?
Matthew Phillips
@matthewp
Nov 12 2015 21:04
yeah, i wouldn't expect it to be used with can.route
but, since it is a can.Map you can do that
Stan Carrico
@shcarrico
Nov 12 2015 21:06
am trying to .. minimize the number of maps in play for my application's property set.
seems to work so far, but was using 2.2.x and noticed this when upgraded to 2.3. opened #2080
thanks!