These are chat archives for canjs/canjs

8th
Dec 2016
Guido Smeets
@gsmeets
Dec 08 2016 10:38
@justinbmeyer any news on when 2.3.28 will be done? It solves a pretty pesky issue for us that I'd love to integrate. Causes a lot of workarounds from what's practical for my team (#2316)
Per Ehnbom
@perehnbom
Dec 08 2016 14:27

I’ve working on migrating an app from CanJS 2 to Canjs3. I would like to use DefineMap instead of the legacy Model, there’s a lot of good features in the new DefineMap, but have come across a couple of problems in the work:

I have a model which in turn has a list of other models as a property, e.g. a project contains a list of todo items.

var Project = can.DefineMap.extend({
  items : {
    Type : Item.List
  }
})

When calling destroy on one of the todo items, they are not removed from the list. Automatic removal on destroy works fine if I instantiate a Item.List directly through can-connect, but not if it’s part of the project model. The same problem applies when I instantiate an Item.List without using can-connect, but by using a constructor with json, e.g. new Item.List(json)

In can.Model, the removal of items relied on the change event bubbling up to the list, but there’s another mechanism used in DefineMap. I do miss the change event bubbling up, it was handy to use when e.g. implementing live bound sorting or other types of live updates on lists.

I have setup 2 jsbins, one with a simple list of items where delete works: http://jsbin.com/mucimi/edit?html,js,console,output, and one with a project with items where delete doesnt work: http://jsbin.com/vohocu/edit?html,js,console,output

For a more comprehensive example, see https://github.com/perehnbom/tryout-canjs3

I wonder if there’s a simple way of achieving this. The only way I can figure out now is to remove items by using boiler plate code in a component or control.

Chasen Le Hara
@chasenlehara
Dec 08 2016 18:05
@gsmeets, thanks for your patience, we’re working on releasing 2.3.28 today
Chasen Le Hara
@chasenlehara
Dec 08 2016 18:29
@phillipskevin, @perehnbom’s issue seems like a bug. What do you think?
Kevin Phillips
@phillipskevin
Dec 08 2016 18:33
in the example where delete doesn’t work… the template is rendering the results of the project promise
which won’t change when you destroy one of the items
I want to look a little deeper into how it is working with the can-connect example
but @perehnbom can definitely open an issue so that it doesn’t get lost
Per Ehnbom
@perehnbom
Dec 08 2016 19:22
Ill open an issue for the destroy case
Kevin Phillips
@phillipskevin
Dec 08 2016 19:52
thanks
Kevin Phillips
@phillipskevin
Dec 08 2016 21:04
@gsmeets 2.3.28 is out