These are chat archives for canjs/canjs

28th
Sep 2018
Justin Meyer
@justinbmeyer
Sep 28 2018 01:38
Manuel Mujica
@m-mujica
Sep 28 2018 18:27
is there a way to add property definition sto can-define/map in an instance level setup? I should probably do it in a static level setup but I have to wait until the instance is being created to know the name of the property.
setup(attrs) {
  this.define[`{attrs.foo}:${attrs.bar}`] = {
    Value: Ctor,
    get: makeGetter(...)
  };
}
that's how the old can-map-define version looked like
@justinbmeyer ^
Manuel Mujica
@m-mujica
Sep 28 2018 18:36
hmm maybe this is what I'm looking for https://canjs.com/doc/can-reflect.defineInstanceKey.html
Mohamed Cherif Bouchelaghem
@cherifGsoul
Sep 28 2018 18:36
Mohamed Cherif Bouchelaghem
@cherifGsoul
Sep 28 2018 18:42
@m-mujica the assign function not for properties definition like in DefineMap
Justin Meyer
@justinbmeyer
Sep 28 2018 18:45
@m-mujica why do they have getters and such then?
Manuel Mujica
@m-mujica
Sep 28 2018 18:47
the getter has logic to filter/sort the values, these props are lists.
Justin Meyer
@justinbmeyer
Sep 28 2018 18:48
is this coming from a model?
Manuel Mujica
@m-mujica
Sep 28 2018 18:48
Yeah, this is a model indeed.
Justin Meyer
@justinbmeyer
Sep 28 2018 18:48
could parseInstanceData do this sorta cleanup before it gets to the DefineMap?

the getter has logic to filter/sort the values, these props are lists.

Is a getter what you want, perhaps a setter? Do these getters operate on anything other than the value?

Manuel Mujica
@m-mujica
Sep 28 2018 18:49
hmmm I see the getter reads from AppState, there is a source list in AppState and that's used to filter the lists in this model... Maybe I can do the same thing in parseInstanceData but I'm not sure
Justin Meyer
@justinbmeyer
Sep 28 2018 20:55
image.png
CanJS's recipes :)