These are chat archives for canjs/canjs

7th
Jul 2016
qantourisc
@qantourisc
Jul 07 2016 08:19
How do I do {{say-hello "{ with a stache sign" }} ?
In 90% { works, but no for stache
Ow "{" works, "{}" doesn't
qantourisc
@qantourisc
Jul 07 2016 08:29
Yep looked at the code
no escape handeling
qantourisc
@qantourisc
Jul 07 2016 09:07
In component.viewModel if you define it by a function, is there anything specific I should do to get bindings to work ?
ok mixing attr
qantourisc
@qantourisc
Jul 07 2016 09:16
I think I see now, you cannot bind to a function
qantourisc
@qantourisc
Jul 07 2016 09:22
I am not entirely sure if this is a bug or not, should I make a report for it ?
qantourisc
@qantourisc
Jul 07 2016 09:34
hmmm I should not be doing this in any case, I should be using can.events
qantourisc
@qantourisc
Jul 07 2016 09:51
Ok the sanest way is to pass an object you will use to dispatch events (and results) trough.
qantourisc
@qantourisc
Jul 07 2016 14:05
This is weird, the value IS available in options.contexts, but not in options.context ?
qantourisc
@qantourisc
Jul 07 2016 14:19
I suspect this is caused by me running return can.stache("stuff")(options.context)
qantourisc
@qantourisc
Jul 07 2016 15:13
a you have to do (options.scope)
qantourisc
@qantourisc
Jul 07 2016 15:26
Ok, I need some more info on how options work, in some cases it appears to automatically detect what values I read, in other cases it doesn't seem to work. I will start reading the source code of canjs, but someone who know will be 1000 times easier.
qantourisc
@qantourisc
Jul 07 2016 16:03
Reading using the context, triggers the observer, using scope does not
Jeremy Miller
@jjm340
Jul 07 2016 16:06
So I have a donejs cordova app that needs to have a script tag for cordova.js on the index.html page. However, when I try to inject it on index.stache it doesn't appear, I"m guessing because the script can't be found, but I know this script will be there in the build. Any suggestions?
qantourisc
@qantourisc
Jul 07 2016 16:33
Is there a internet facing version ?
dislcaimer: i only know canjs
Kevin Phillips
@phillipskevin
Jul 07 2016 16:52
@jjm340 you might want to ask on the donejs gitter
I would suggest building your cordova app for android and trying to debug it with the chrome dev tools
see if there’s a steal error/warning
qantourisc
@qantourisc
Jul 07 2016 17:06

Ok I finally found how to do it, but I get the feeling i'm writing code that is WAAAY to deep into canjs:

var stache_helper_comp = function(comp,options){
    let value=undefined;
    if (can.isFunction(value))
        value=comp();
    else
        value=comp;

    if( options.scope.read("appstate.loaded."+value,{isArgument:true}).value ){
        return can.stache(
            "<"+can.esc(value)+""/>"
        )(options.scope);
    }

    return spinner( //Renders a component-is-loading sign
        {spinner_alt:"Loading or missing comp: "+can.esc(value)}
    );
};

Is this ok? Or are there better ways ?

Dovid Bleier
@dbleier
Jul 07 2016 18:12
how can I trigger "inserted" and "removed" events in tests in order to test those methods?
Kevin Phillips
@phillipskevin
Jul 07 2016 18:17
add and remove the component from the DOM
Dovid Bleier
@dbleier
Jul 07 2016 18:18
meaning $('body').append(my-comp);?
Kevin Phillips
@phillipskevin
Jul 07 2016 18:19
yeah
Dovid Bleier
@dbleier
Jul 07 2016 18:19
ok, thanks
Kevin Phillips
@phillipskevin
Jul 07 2016 18:19
it’s not super easy to test that stuff
Thomas Sieverding
@Bajix
Jul 07 2016 21:55
What’s the secret sauce to making a can.List w/ type ‘*'
Is that a thing even?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Jul 07 2016 21:57
@Bajix what you mean? you need a typed list?
Thomas Sieverding
@Bajix
Jul 07 2016 21:57
I’d like a can.List of PJSO's
I want to be able to observe add/remove/length
Mohamed Cherif Bouchelaghem
@cherifGsoul
Jul 07 2016 21:58

yes you can

list.bind('remove',fn)
list.bind('change',fn)

etc

Thomas Sieverding
@Bajix
Jul 07 2016 21:59
I don’t want it to automatically convert members
Mohamed Cherif Bouchelaghem
@cherifGsoul
Jul 07 2016 22:00
I dont understand what you mean! you want to keep the objects as POJO's?
not can.Map objects?
Thomas Sieverding
@Bajix
Jul 07 2016 22:01
yep
An observable array w/out type conversion
I want to be able to observe add/remove/length
Mohamed Cherif Bouchelaghem
@cherifGsoul
Jul 07 2016 22:02
I think can.compute can help you to make it
Jeremy Miller
@jjm340
Jul 07 2016 22:02
You tried type: '*', Value: Array?
Thomas Sieverding
@Bajix
Jul 07 2016 22:03
@jjm340 That’s not the issue. I want a can.List, but I don’t want it to convert members into can.Map's
Mohamed Cherif Bouchelaghem
@cherifGsoul
Jul 07 2016 22:13
@Bajix list.attr() returns the JS plain objects
Thomas Sieverding
@Bajix
Jul 07 2016 22:13
No I get that; I’m asking how to override the type behavior on lists
@Bajix Preventing Arrays and Objects from Automatic Conversion
Thomas Sieverding
@Bajix
Jul 07 2016 22:17
That applies to properties on can.Map's
Mohamed Cherif Bouchelaghem
@cherifGsoul
Jul 07 2016 22:17
what is your use case? you dont use can.Map.define?
Thomas Sieverding
@Bajix
Jul 07 2016 22:17
I do, but that isn’t applicable here
can.Map.define sets up the behavior on can.Map’s only
I want to prevent can.List from turning members into can.Map - seemingly the only approach is with Map: Map
I thought @justinbmeyer had something for overriding this on the can.List prototype