These are chat archives for canjs/canjs

10th
Nov 2016
Justin Meyer
@justinbmeyer
Nov 10 2016 04:26
@halcyonandon yes, there is a long standing can-component issue related to this: canjs/can-component#10
A big issue is going to be view bindings
however, my hope is that with can-define being it's own thing ... we might be able to soon make custom elements with can-define-ed properties
this way the properties you define would be on your custom element
But this will be expensive in browsers that don't support registerElement
Juarez Rudsatz
@juarezr
Nov 10 2016 05:11
In PropDefinition of can-define/map/map v3, what's the difference between 'value' and 'Value' and between 'type' and 'Type'?
I'm trying to set a default value for a property used in a stache template of a can-component but have the value 'undefined'.
Gregg Roemhildt
@roemhildtg
Nov 10 2016 14:04
@juarezr capitalized Value and Type are for constructors. Lowercase value are for primitive types or a function that returns something. Lowercase type is for specifying the primitive type, like date, number...etc. Its all detailed here: http://v3.canjs.com/doc/can-define.types.propDefinition.html
Juarez Rudsatz
@juarezr
Nov 10 2016 14:32
Thanks. Another question: in propDefinition type and value are mutually exclusive?
var MyModel = DefineMap.extend({
visible: { value: true, type: 'boolean' }
}
export default Component.extend({
tag: 'my-tag',
ViewModel: MyModel,
view: stache("{{#if visible}}<content></content>{{else}}<!-- my-tag visible=false -->{{/if}}"),
}
The default value of 'visible' is not showing in the stache template:
Gregg Roemhildt
@roemhildtg
Nov 10 2016 14:59
Looks right. It works for me: http://jsbin.com/xonucefaca/edit?html,js,output
Nico R.
@nriesco
Nov 10 2016 16:13
what is the “correct” way of adding an instance of a component and setting some configuration options/parameters? something like this <my-component param1=“one” param2=2 /> It can be achieved with bindings but seems like it's not the proper way.
I want to have two or more instances of the same component like this:
<my-component param1=“one” />
<my-component param1=“two” />
...
<my-component param1=“cool” />
Kevin Phillips
@phillipskevin
Nov 10 2016 16:17
I think that’s fine
what makes you unsure about it?
Nico R.
@nriesco
Nov 10 2016 16:17
so that works?
and within the component? how do I read that value? this.param1? this.attr(‘param1’)?
Kevin Phillips
@phillipskevin
Nov 10 2016 16:19
that should set those values on the viewModel
so just like you would read any other vm property
Nico R.
@nriesco
Nov 10 2016 16:23
it works, thanks again @phillipskevin
Kevin Phillips
@phillipskevin
Nov 10 2016 16:23
yeah no worries
Nico R.
@nriesco
Nov 10 2016 16:29
is it possible to pass an object? param1={some:1, value: false}
you can always pass a string and parse it on the other end but maybe there is some already defined syntax
Kevin Phillips
@phillipskevin
Nov 10 2016 16:30
you can use binding and pass it an object that you create in the parent scope
{param1}=“myObj”
Nico R.
@nriesco
Nov 10 2016 16:31
will this work?
Kevin Phillips
@phillipskevin
Nov 10 2016 16:31
but then you’d need to create myObj in js somewhere
Nico R.
@nriesco
Nov 10 2016 16:31
{param1}=“myObj[‘key’]"
Kevin Phillips
@phillipskevin
Nov 10 2016 16:32
yeah, that should work
in 3.0
[] are new to can-stache in 3.0
Nico R.
@nriesco
Nov 10 2016 16:33
ok, so maybe the correct way would be {param1}=“configObject[‘key’]”
Nico R.
@nriesco
Nov 10 2016 17:00
quick question: If I have this {{displayValue}} but I want the inside (displayValue) to be variable, can I do something like this: {{$displayValue}}?
I could set a ‘global’ object and do this {{globaObject[‘displayValue’]}} but again, it does not feel like the proper way (and I don’t even know if it will work)
Kevin Phillips
@phillipskevin
Nov 10 2016 17:02
you can change displayValue when using {{displayValue}}
maybe I’m not understanding the question
Nico R.
@nriesco
Nov 10 2016 17:04
mmm maybe my question is not a question at all…
Frank Lemanschik
@frank-dspeed
Nov 10 2016 17:29
Nico normal steal exports global objects
if you you use can3 maybe google can v3 leakScope
if you need to leakScope to a sub component defaults changed to false
Juarez Rudsatz
@juarezr
Nov 10 2016 18:51
@roemhildtg : Fixed -> 1. Close browser -> 2. Open browser
Justin Meyer
@justinbmeyer
Nov 10 2016 18:56
we are about to publish 3.0.0 ... (though don't tweet about it yet ... we just have all tests passing)
actually ... we're waiting on @daffl to return from lunch I think
Frank Lemanschik
@frank-dspeed
Nov 10 2016 19:35
ya
good day :D
can drop many workarounds then
Matthew Phillips
@matthewp
Nov 10 2016 21:14
Justin Meyer
@justinbmeyer
Nov 10 2016 21:27
Ok, 3.0.0 is published to npm
Frank Lemanschik
@frank-dspeed
Nov 10 2016 21:27
may god bless it