These are chat archives for canjs/canjs

3rd
Nov 2017
Gregg Roemhildt
@roemhildtg
Nov 03 2017 14:57
Good morning :) I'm wondering about adding canjs observability to a third party list-like structure. It is technically more map-like, because its not an array. Its items are stored in a map.items property. But it does have forEach, length properties and other array functions.
Its a little weird
Brad Momberger
@bmomberger-bitovi
Nov 03 2017 15:46
DefineList doesn't subclass Array, so that's an indication that it's possible.
For Can 3.x there are a few special events that get fired when the array-like part of a DefineList or CanList changes. You can pretty much do everything with the "add" and "remove" events.
In Can 4.x we don't do the event system and those named events are gone. Instead it all gets rolled up into patches and you dispatch to anything that listens to your object using @@can.onPatches
The patches are what you would get if you took the old state of the object and the new state, and ran them through can-util/js/diff-object/ and/or can-util/js/diff-array/
Kevin Phillips
@phillipskevin
Nov 03 2017 15:49
@justinbmeyer will be giving a presentation about this the first week of December
maybe we can convince him to write a blog post also
Brad Momberger
@bmomberger-bitovi
Nov 03 2017 15:50
If you look at the can-observe major branch you can see the patches being generated on key sets/deletes and array mutations.
Gregg Roemhildt
@roemhildtg
Nov 03 2017 15:52
Okay I think I'll hold off on this till 4.x. I do enjoy a good blog post ;)
This one is super helpful
Gregg Roemhildt
@roemhildtg
Nov 03 2017 16:01
Actually would be as simple as implementing Symbol.iterator? I think I remember reading about DefineList iterator somewhere
Brad Momberger
@bmomberger-bitovi
Nov 03 2017 16:02
Look on my Works, ye Mighty, and despair! https://github.com/canjs/can-define/blob/master/list/list.js#L1602
If you want live updates, though, you'll need more than just implementing an iterator.
Gregg Roemhildt
@roemhildtg
Nov 03 2017 16:03
lol. Yep I'll start with that. Thanks @bmomberger-bitovi
Chasen Le Hara
@chasenlehara
Nov 03 2017 17:16
We’re starting discussion of the survey proposals right now: https://www.youtube.com/watch?v=ieZJrPwSZYQ