These are chat archives for canjs/canjs

11th
Aug 2017
Nico R.
@nriesco
Aug 11 2017 01:12

I'm really confused when declaring observables/variables within a defineMap. I think this is probably a basic topic, but I don't know how it really works.

I've seen (so far) the following syntaxes:

export const ViewModel = DefineMap.extend({
  var1: { type: String, value: 'super' },
  var2: { type: 'string', value: 'super' },
  var3: { value: 'hello', serialize: false},
  var4: 'string',
  var5: 'any',
  var6: '*',

})

I don't really know their differences and when to use them. As for the serialize option does it mean that ViewModel.serialize() would return everything except from attributes with serialize: false option?

Thanks

Jeroen Cornelissen
@jeroencornelissen
Aug 11 2017 06:31
@nriesco yes, .serialize() doesn’t return serialize: false properties. I see them as “private” properties.
var1 is incorrect and should be Type with a capital T: Type: String or Type: MyCustomMap
var5 & var6 are identical, it means that your var can be anything. If you pass an object to type: ‘*’it stays an object and isn’t converted to a DefineMap.
AntonProkofyev
@AntonProkofyev
Aug 11 2017 11:41
Hi all is there any extended guide for algebra?
Kevin Phillips
@phillipskevin
Aug 11 2017 13:37
@nriesco https://canjs.com/doc/can-define.types.propDefinition.html is the best place to look to learn about the differences
Nico R.
@nriesco
Aug 11 2017 14:31
thanks @phillipskevin it looks like that plus https://canjs.com/doc/can-define.types.html will help me understand (also thanks @jeroencornelissen !)
Kevin Phillips
@phillipskevin
Aug 11 2017 14:33
there's also https://www.youtube.com/watch?v=eXp3m-ZlL4Y if you prefer a video
Justin Meyer
@justinbmeyer
Aug 11 2017 15:31
Justin Meyer
@justinbmeyer
Aug 11 2017 15:39
actually, it will be here: https://www.youtube.com/watch?v=R4F_U_BwwWM