These are chat archives for canjs/canjs

24th
Jan 2018
Nico R.
@nriesco
Jan 24 2018 01:11
how can I compare a variable to a value in stache? I tried {{#if(myVar > 0)}} but it does not seem to work? Should it work?
I mean directly using the helper/tag like if, I don’t want to create a function to compare greater than
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 05:12
The Stache engine doesn't have any support for math or comparisons, other than the native #eq helper. If you want to do inequality comparisons, you should be able to directly port the #compare Handlebars helper from OOCSS into your project: https://github.com/stubbornella/oocss/blob/0c146a17e13d7b9d5797ffbf2805ce482cbddd9b/oocss/tools/files/handlebars.helpers.js
Frank Lemanschik
@frank-dspeed
Jan 24 2018 06:57
@bmomberger-bitovi do you know the state of stache helpers in canjs4?
in the current pre it don't works anymore to register stache helpers
i did a workaround and define my helpers in the view Model as HashMatch method
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:08
The tests for registering and using helpers still exist in prereleases
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:08
reality showed that it now fails rendering
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:08
The major thing of note is that all calls to helpers should use Call syntax
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:08
and is showing the js code
ok myabe that works i can try that
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:09
If you don't have () in your helper tag, it may not actually call the helper function
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:09
it calls it but returns the code and errors
so i get real clear text js code in the browser rendered
from the helper
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:10
Not surprising, since our default is now to not call functions. you get the result of the function's toString()
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:10
ok then i can inform you toString works
and for me at last it was a big supprise i was so angry
:D
but then i coded the methods on viewModel
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:10
Are you using can-migrate?
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:11
thanks for the info
no i don't use can-migrate i do it all from hand and only because feathersJS is broken
and i now want to recode the app with feathers 3 + can4
and do pull requests
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:12
OK.
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:25
@bmomberger-bitovi wanted to look into suggestions from can migrate
{ Error: spawn E2BIG
    at _errnoException (util.js:1003:13)
    at ChildProcess.spawn (internal/child_process.js:340:11)
    at Object.exports.spawn (child_process.js:499:9)
    at module.exports (/usr/local/lib/node_modules/can-migrate/node_modules/execa/index.js:144:26)
    at series (/usr/local/lib/node_modules/can-migrate/bin/can-migrate.js:120:12)
    at /usr/local/lib/node_modules/can-migrate/node_modules/promise-map-series/index.js:11:14
    at tryCatch (/usr/local/lib/node_modules/can-migrate/node_modules/rsvp/dist/rsvp.js:525:12)
    at invokeCallback (/usr/local/lib/node_modules/can-migrate/node_modules/rsvp/dist/rsvp.js:538:13)
    at publish (/usr/local/lib/node_modules/can-migrate/node_modules/rsvp/dist/rsvp.js:508:7)
    at flush (/usr/local/lib/node_modules/can-migrate/node_modules/rsvp/dist/rsvp.js:2415:5) errno: 'E2BIG', code: 'E2BIG', syscall: 'spawn' }
i get flooded with that
so it wouldn't help me a lot any way
:D
$ getconf ARG_MAX
2097152
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:28
Someone reported E2BIG on the company Slack today
Apparently you have to add **/* to the end of any directory reference, turning it into a glob, to make it work correctly?
Anyway, I wanted to show you this:
Screen Shot 2018-01-24 at 2.26.22 AM.png
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:29
yes i see it did really do toString
@bmomberger-bitovi i still get the E2BIG
but thats possible as this is a big application
some 100+ components
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:31
Might try running it on just one component dir first, and then expand until it happens again.
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:31
no i will recode that package
i will code it with streams
this way it will run on any system
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:32
Anyway, @Sinjhin may have some more insight since he was the one that encountered the problem.
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:32
i will simply recode can-migrate as the idea is cool
but it needs to be able to handle more and use less ram cpu
i will code it with streams so it has permernent ram cpu usage and can handle any size
E2BIG means simply that this spawn call got called with over 2097152 Arguments
i think some one simply putted a file list behind that :)
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:49
@bmomberger-bitovi do you know the current state of routeUrl helper?
as that is removed in can4 and not in can-stache-helpers which is a placeholder i think?
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:54
I didn't know that existed, but I was already off OS and on client work by the time that was more than a doc file.
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:55
oh cool now you know it :)
all helpers get removed out of stache
and get own repositorys
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 07:58
Except for "debugger", "each", "eachOf", "index", "if", "is", "eq", "unless", "with", "console", "data", "switch", "joinBase"
which are technically helpers but are still stache built-ins
Frank Lemanschik
@frank-dspeed
Jan 24 2018 07:59
the basics
yes i understand
wow its rendering again :)
Brad Momberger
@bmomberger-bitovi
Jan 24 2018 08:04
Great.
I'm going to bed.
Frank Lemanschik
@frank-dspeed
Jan 24 2018 08:18
sleep well
i can handle the channel so long :D as i am the only EU member hére no one will ask something
:D
Nico R.
@nriesco
Jan 24 2018 09:09
thanks @bmomberger-bitovi that seems like a nice way to use comparison, like this part: https://github.com/stubbornella/oocss/blob/0c146a17e13d7b9d5797ffbf2805ce482cbddd9b/oocss/tools/files/handlebars.helpers.js#L48-L58
Kevin Phillips
@phillipskevin
Jan 24 2018 14:09
@frank-dspeed helpers are working fine in can4. is there an issue you're seeing?
RyanMilligan
@RyanMilligan
Jan 24 2018 18:03

We're encountering the issue described here: https://forums.donejs.com/t/binding-error-when-removing-form-element/791

We also have a massive memory leak when navigating or removing elements that seems to be related to leaking event handlers, so I suspect they may be related. Has anything been found on this issue?

Frank Lemanschik
@frank-dspeed
Jan 24 2018 19:34
@phillipskevin its solved
the problem was that all helpers got handled as expected by can4
so i got only a toString() representation because not doing helperName()
helperName now gets automatic judged as value so he shows it as string
Kevin Phillips
@phillipskevin
Jan 24 2018 19:48
k thanks
Frank Lemanschik
@frank-dspeed
Jan 24 2018 20:06
@phillipskevin
-make-delegate-event-tree.js:27 Uncaught TypeError: cur.matches is not a function
    at Object.eval (http://master.peep:3030/node_modules/can-dom-events/helpers/-make-delegate-event-tree.js:27:15)
    at String.eval (http://master.peep:3030/node_modules/can-reflect/reflections/shape/shape.js:396:21)
    at Object.eachListLike (http://master.peep:3030/node_modules/can-reflect/reflections/shape/shape.js:327:17)
    at Object.eachIndex (http://master.peep:3030/node_modules/can-reflect/reflections/shape/shape.js:289:16)
    at Object.eachKey (http://master.peep:3030/node_modules/can-reflect/reflections/shape/shape.js:394:16)
    at Object.each (http://master.peep:3030/node_modules/can-reflect/reflections/shape/shape.js:260:16)
    at HTMLHtmlElement.handler.delegated.(anonymous function) (http://master.peep:3030/node_modules/can-dom-events/helpers/-make-delegate-event-tree.js:24:16)
this is what i am sticking around now
:D
i am on the journy to find cur.match
:D
Frank Lemanschik
@frank-dspeed
Jan 24 2018 20:22
@phillipskevin now i am sure i found some real problem :)
i puted a console.log into this -make delegate stuff and let it return ev.target === cur
because i wanted to know why cur.matches is not a function
it turns out ev.target === document.body as html
Frank Lemanschik
@frank-dspeed
Jan 24 2018 20:33
also solved :) problem was maybe that my new internel helper caused that via return stache(template)(this); inside a value function from inside a viewModel
it can get ignored its probally a antipattern
Runn Vermel
@runn-vermel
Jan 24 2018 23:44
i have a new issue that just popped up: i have a select tag, and i'm running a #each loop inside of it. i'm calling a method on change, and i'm trying to pass the selected element's value. this code has historically worked with %element.value - although, for whatever reason, that's not working now. i tried updating it to scope.element.value, like the warning suggested, but i'm still not getting a value back.
<select class="form-control" {($value)}="trainsByPlatform[platform.name]" ($change)="upsertInitialRelease(platform.name, scope.element.value)"> <option></option> {{#each trains[platform.name] as train}} <option value="{{train.name}}">{{train.name}}</option> {{/each}} </select>
any ideas?
Runn Vermel
@runn-vermel
Jan 24 2018 23:49
it seems as the scope.element portion is working, but the value isn't being set on the select when an option is chosen
Morgan Heimbeck
@Xitstrategies
Jan 24 2018 23:52
change may trigger before value is set... try putting a timeout in the upsertInitialRelease function?
Runn Vermel
@runn-vermel
Jan 24 2018 23:55
hmm, if i do that, i'll still be receiving the value as empty tough.
though*
maybe if i put the timeout in the call with an anonymous function.. let me check
oh, wait, that's a v2 link
argh
Morgan Heimbeck
@Xitstrategies
Jan 24 2018 23:56
which version of can are you using?
Runn Vermel
@runn-vermel
Jan 24 2018 23:57
3