These are chat archives for canjs/canjs

7th
Feb 2018
Jeroen Cornelissen
@jeroencornelissen
Feb 07 2018 09:14
What is the best practice for can-component helpers, do you even need them?
You could also add functions in your VM, no?
Is it better to do {{#isSelected(item)}} which returns options.fn() then {{#if(isSelected(item))}} which returns true?
Frank Lemanschik
@frank-dspeed
Feb 07 2018 09:15
i don't understand the question
your question is in this example like
is it better to set const notTrue = null || undefined || false || 0
;)
this stugg
this stuff is only importent if your code style needs it
but all this will work you could maybe do some Research and test which method is fastest on execution
and publish the benchmarks including plattform
Jeroen Cornelissen
@jeroencornelissen
Feb 07 2018 09:17
My question is do you need to use can-component helpers, or not?
Frank Lemanschik
@frank-dspeed
Feb 07 2018 09:17
some methods are faster as others depending on the environment
i need to google what that even is :)
Frank Lemanschik
@frank-dspeed
Feb 07 2018 09:18
ah i understand i don't know why they are called this way
this are can-stache helpers
but this means on component level
this is only for your code style and completness
you don't need them you can use helpers placed on the viewModel
or register global stache helpers this is only a method to define them on a other place
Jeroen Cornelissen
@jeroencornelissen
Feb 07 2018 09:20
That is the question :smile:
What is the best practice?
Frank Lemanschik
@frank-dspeed
Feb 07 2018 09:20
depending on the size of the code i would say
and on the situation in other models
if you got for example a component that stores a lot of state like my transaction component for example
it can be usefull to place the helpers in the component to have it on a diffrent place and dont get a viewModel that has 100 + functions
transactions for me include data like persons, all kind of state like start stop status
so the main vm already has a lot of propertys even without helpers that are setting that
lets keep it simple if your viewModel needs more then 10 helpers
you should maybe place them in the component to seperate them
:D
if you use the same helper on many places register him as global stache helper
Kevin Phillips
@phillipskevin
Feb 07 2018 15:18
I would put as much as you can in the viewModel
it's easier to write unit tests for the viewModel
Paul Tichonczuk
@tracer99
Feb 07 2018 18:26
is there any examples of a carousel built using CanJS out there?
Julian
@pYr0x
Feb 07 2018 20:02
is there no "can-jquery/legacy" for can 4.0?
Kevin Phillips
@phillipskevin
Feb 07 2018 20:03
currently, there is no can-jquery for 4.0
we plan to drop support for /legacy though, when can-jquery@4.0 is released
although I'm not sure when that will be
Julian
@pYr0x
Feb 07 2018 20:04
:(
Kevin Phillips
@phillipskevin
Feb 07 2018 20:04
there is an issue: canjs/can-jquery#181
can-types isn't really used anymore internally, so supporting /legacy would be difficult
(or impossible)
Julian
@pYr0x
Feb 07 2018 20:06
legacy only wrap jquery around can control elements?
Kevin Phillips
@phillipskevin
Feb 07 2018 20:06
yes
Julian
@pYr0x
Feb 07 2018 20:06
i have events in my can control ... so thats does not work without can-jquery
Kevin Phillips
@phillipskevin
Feb 07 2018 20:07
events that are triggered by jquery?
$.dispatch ?
Julian
@pYr0x
Feb 07 2018 20:07
"#expand-all click": function (el, ev) {
e.g.
Kevin Phillips
@phillipskevin
Feb 07 2018 20:08
I don't think that's because of can-jquery
did you try "{element} #expand-all click"
Julian
@pYr0x
Feb 07 2018 20:09
not yet
i think i will stick to can3. i am right into a project and tried to upgrade ;)
Kevin Phillips
@phillipskevin
Feb 07 2018 20:11
totally fine