These are chat archives for canjs/canjs

1st
Dec 2017
DaveO
@DaveO-Home
Dec 01 2017 00:05
@phillipskevin @justinbmeyer - I ran the code through Babel and the Component issue went away, however I think there is now a bigger issue, -- wherever I use stache is get: Uncaught ReferenceError: weirdAttribute is not defined thrown;
index.js:5597 Uncaught ReferenceError: weirdAttribute is not defined
at Object.attrEnd (index.js:5597)
at callAttrEnd (index.js:7714)
at Function.HTMLParser.parseAttrs (index.js:7718)
at parseStartTag (index.js:7681)
at HTMLParser (index.js:7702)
at stache (index.js:5588)
at Object.success (index.js:86)
at fire (jquery.js:3317)
at Object.fireWith [as resolveWith] (jquery.js:3447)
at done (jquery.js:9272)
Justin Meyer
@justinbmeyer
Dec 01 2017 01:15
where is index.js?
what does the code around that look like?
DaveO
@DaveO-Home
Dec 01 2017 01:45

package.json

    {
      "name": "browserify-acceptance",
      "version": "1.0.0",
      "description": "acceptance tests under browserify",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "keywords": [
        "acceptance test",
        "browserify",
        "karma",
        "jasmine",
        "canjs",
        "bootstrap"
      ],
      "author": "daveo",
      "contributors": [],
      "dependencies": {
        "bootstrap": "^4.0.0-beta",
        "can": "^3.10.1",
        "can-define": "^1.4.5",
        "can-view-callbacks": "^3.2.0",
        "font-awesome": "^4.7.0",
        "jquery": "^3.2.1",
        "lodash": "^4.17.4",
        "moment": "^2.18.1",
        "pdfjs-dist": "^1.9.528",
        "popper.js": "^1.0.0",
        "tablesorter": "^2.28.15"
      },
      "license": "ISC",
      "devDependencies": {
        "babel-preset-env": "^1.6.1",
        "babel-preset-es2015": "^6.24.1",
        "browser-sync": "^2.18.13",
        "browserify": "^14.4.0",
        "browserify-css": "^0.14.0",
        "browserify-shim": "^3.8.14",
        "buffer": "^5.0.8",
        "can-make-rest": "^0.1.2",
        "cssify": "^1.0.3",
        "csslint": "^1.0.5",
        "del": "^3.0.0",
        "gulp-babel": "^7.0.0",
        "gulp-bootlint": "^0.8.1",
        "gulp-copy": "^1.0.1",
        "gulp-csslint": "^1.0.0",
        "gulp-eslint": "^4.0.0",
        "gulp-exec": "^2.1.3",
        "gulp-remove-code": "^1.0.2",
        "gulp-sourcemaps": "^2.6.1",
        "gulp-strip-code": "^0.1.4",
        "gulp-uglify": "^3.0.0",
        "jasmine-core": "^2.8.0",
        "jasmine-jquery": "^2.1.1",
        "karma": "^1.7.1",
        "karma-browserify": "^5.1.1",
        "karma-chrome-launcher": "^2.2.0",
        "karma-commonjs": "^1.0.0",
        "karma-firefox-launcher": "^1.0.1",
        "karma-jasmine": "^1.1.0",
        "karma-jasmine-jquery": "^0.1.1",
        "karma-mocha-reporter": "^2.2.4",
        "karma-opera-launcher": "^1.0.0",
        "vinyl-buffer": "^1.0.0",
        "vinyl-source-stream": "^1.1.0",
        "watchify": "^3.9.0"
      },
      "browser": {
        "app": "./appl/js/app.js",
        "basecontrol": "./appl/js/utils/base.control.js",
        "config": "./appl/js/config.js",
        "default": "./appl/js/utils/default.js",
        "helpers": "./appl/js/utils/helpers.js",
        "menu": "./appl/js/utils/menu.js",
        "pager": "./node_modules/tablesorter/dist/js/extras/jquery.tablesorter.pager.min.js",
        "pdf": "./appl/js/controller/pdf.js",
        "router": "./appl/js/router.js",
        "setup": "./appl/js/utils/setup.js",
        "start": "./appl/js/controller/start.js",
        "table": "./appl/js/controller/table.js",
        "apptest": "./appl/jasmine/apptest.js",
        "contacttest": "./appl/jasmine/contacttest.js",
        "domtest": "./appl/jasmine/domtest.js",
        "logintest": "./appl/jasmine/logintest.js",
        "routertest": "./appl/jasmine/routertest.js",
        "toolstest": "./appl/jasmine/toolstest.js",
        "popper": "./node_modules/popper.js/dist/umd/popper.js"
      },
      "browserify": {
        "transform": [
          "browserify-shim"
        ]
      },
      "browserify-shim": {
        "popper": "Popper",
        "bootstrap": {
          "depends": [
        "jquery:jQuery",
        "popper:Popper"
          ]
        }
      }
    }

index.js

window.jQuery = window.$ = require('jquery');

const App = require("app"), 
    Router = require("router"), 
    Default = require("default"), 
    Setup = require("setup"), 
    Helpers = require("helpers"), 
    Config = require("config");
require("pager"); 

App.init(Default);

const Route = Router.init();

Setup.init();

//removeIf(production)
//Code between the ..start and ..end tags will be removed by the BlockStrip plugin during the production build.
//testit is true if running under Karma - see testapp_dev.html
if (typeof window.testit !== "undefined" && window.testit) {

    const apptest = require("apptest").apptest;

    //Run acceptance tests.
    apptest(Route, Helpers, App);

    jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
    setTimeout(() => {
    __karma__.start(); //<===== Very Important - executed here!!
    }, 500); 
}
Justin Meyer
@justinbmeyer
Dec 01 2017 01:56
Meaning, where is weirdAttribute?
@/all I'm going over how can-observation works tomorrow: https://twitter.com/canjs/status/936414611972198400
(please like & subscribe to our youtube channel if you like getting these sorts of walk-throughs)
Justin Meyer
@justinbmeyer
Dec 01 2017 02:02

btw, here's another fun tweet (to like/retweet ... stare blankly at ... whatever :-) )

https://twitter.com/canjs/status/936252675515191297

DaveO
@DaveO-Home
Dec 01 2017 02:02
var decodedAttrName=attributeEncoder.decode(attrName);weirdAttribute=!!wrappedAttrPattern.test(decodedAttrName)||!!colonWrappedAttrPattern.test(decodedAttrName);if(weirdAttribute&&!attrCallback){dev.warn("unknown attribute binding "+decodedAttrName+". Is can-stache-bindings imported?");}//!steal-remove-end -- in module.exports=ns.simpleObservable=function simpleObservable(initialValue){var value=ini
Justin Meyer
@justinbmeyer
Dec 01 2017 02:03
@DaveO-Home can you paste that in between some ``` ?
or maybe run through a prettifier
DaveO
@DaveO-Home
Dec 01 2017 02:04
var decodedAttrName=attributeEncoder.decode
(attrName);weirdAttribute=!!wrappedAttrPattern.test(decodedAttrName)||!!colonWrappedAttrPattern.test(decodedAttrName);if(weirdAttribute&&!attrCallback){dev.warn("unknown attribute binding "+decodedAttrName+". Is can-stache-bindings imported?");}//!steal-remove-end -- in module.exports=ns.simpleObservable=function simpleObservable(initialValue){var value=ini
btw, it looks like you pasted the same thing again (not sure if you tried to clean it up)
do you know which line / statement it is breaking on?
DaveO
@DaveO-Home
Dec 01 2017 02:07
var decodedAttrName=attributeEncoder.decode
(attrName);weirdAttribute=!!wrappedAttrPattern.test
(decodedAttrName)||!!colonWrappedAttrPattern.test
(decodedAttrName);if(weirdAttribute&&!attrCallback)
{dev.warn("unknown attribute binding
"+decodedAttrName+". Is can-stache-bindings
imported?");}//!steal-remove-end -- in
module.exports=ns.simpleObservable=function
simpleObservable(initialValue){var value=ini
Justin Meyer
@justinbmeyer
Dec 01 2017 02:08
hmm, that didn't help either ... odd
you have to do: CODE
hard for me to show
Its
```
CODE
```
DaveO
@DaveO-Home
Dec 01 2017 02:09
This line:
weirdAttribute=!!wrappedAttrPattern.test(decodedAttrName)||!!colonWrappedAttrPattern.test(decodedAttrName);if(weirdAttribute&&!attrCallback){dev.warn("unknown attribute binding "+decodedAttrName+". Is can-stache-bindings imported?");}//!steal-remove-end
Brad Momberger
@bmomberger-bitovi
Dec 01 2017 02:20
hey we fixed the weirdAttribute thing recently
That error happens when all of your code runs in strict mode
upgrade can-stache to 3.14.2 and that should go away
I found it when I misconfigured some coverage tests and it injected "use strict" into every js file
DaveO
@DaveO-Home
Dec 01 2017 02:25
I'm running can-stache@3.13.2 - not using 'strict'
How do I override can-stache with it is a dependency of 'can'
Brad Momberger
@bmomberger-bitovi
Dec 01 2017 02:32
I'm pretty sure strict mode has been added to your script bundle somewhere, otherwise this wouldn't cause an error; even if you didn't add it, it just has to be included by another file that went into your bundle
Now as for the question of what to do about it, if you're using the can package, you can fork it on github and try to update the deps. this may not be easy, as the stateful dependencies like can-cid and can-stache-key may mismatch.
DaveO
@DaveO-Home
Dec 01 2017 02:36
I just did npm install can-stache@3.14.2 but have not tried it yet......
Brad Momberger
@bmomberger-bitovi
Dec 01 2017 02:36
It would definitely be better to lobby the open source dev team to make a patch release of can that includes the strict mode fixes.
Brad Momberger
@bmomberger-bitovi
Dec 01 2017 02:44
Incidentally, there is a Babel plugin that removes strict mode from all files that get transpiled: https://www.npmjs.com/package/babel-plugin-transform-remove-strict-mode
that might get you unblocked
DaveO
@DaveO-Home
Dec 01 2017 02:46
@bmomberger-bitovi Thanks for the info will try latter-thanks...
DaveO
@DaveO-Home
Dec 01 2017 02:53
@bmomberger-bitovi - I use gulp so added this and it works; presets: [
['es2015', {modules: false}]
]
Brad Momberger
@bmomberger-bitovi
Dec 01 2017 02:53
:+1:
Gregg Roemhildt
@roemhildtg
Dec 01 2017 14:02
Hey guys, still getting lots of call stack exceeded errors. I've been able to find and fix a few (they were mostly properties that just weren't defined, but worked in earlier versions)
steal.js:140 Potentially unhandled rejection [1] RangeError: Maximum call stack size exceeded
    at Scope._read (http://greggtest.cityhall.com/gis/static_apps/can-navigate/node_modules/can-view-scope/can-view-scope.js:254:18)
    at Scope.read (http://greggtest.cityhall.com/gis/static_apps/can-navigate/node_modules/can-view-scope/can-view-scope.js:228:15)
    at ScopeKeyData.read (http://greggtest.cityhall.com/gis/static_apps/can-navigate/node_modules/can-view-scope/compute_data.js:103:32)
    at Observation.start (http://greggtest.cityhall.com/gis/static_apps/can-navigate/node_modules/can-observation/can-observation.js:268:26)
    at Observation.eval (http://greggtest.cityhall.com/gis/static_apps/can-navigate/node_modules/can-observation/can-observation.js:714:8)
    at Object.eval [as onValue] (http://greggtest.cityhall.com/gis/static_apps/can-navigate/node_modules/can-reflect/reflections/observe/observe.js:23:18)
    at ScopeKeyData.eval (http://greggtest.cityhall.com/gis/static_apps/can-navigate/node_modules/can-view-scope/compute_data.js:126:14)
    at Object.eval [as onValue] (http://greggtest.cityhall.com/gis/static_apps/can-navigate/node_modules/can-reflect/reflections/observe/observe.js:23:18)
    at Function.Observation.temporarilyBind (http://greggtest.cityhall.com/gis/static_apps/can-navigate/node_modules/can-observation/can-observation.js:685:13)
    at Object.getObservableValue_fromKey (http://greggtest.cityhall.com/gis/static_apps/can-navigate/node_modules/can-stache/src/expression-helpers.js:51:13)
In this particular case, I've got a component that uses partials to render different data views of a connection (list, edit, details, etc)
The value that I think its struggling with is view.canEdit which determines whether the user can edit the data. If so a form is shown.
Gregg Roemhildt
@roemhildtg
Dec 01 2017 14:09
If I place a console log in the valueReaders read function of the can-stache-key file, it logs a template context of the edit partial until it crashes
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:04
And if I place the {{debugger}} tag in the edit partial template, it looks like its getting rendered repeatedly for some reason
Kevin Phillips
@phillipskevin
Dec 01 2017 15:04
are you able to reproduce in a small example?
we can definitely prioritize a fix if you can narrow it down
Frank Lemanschik
@frank-dspeed
Dec 01 2017 15:06
@phillipskevin can we chat fast private?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:06
That's the thing, I can't even reproduce it across all my data pages that use this component...Its only happening in one scenario right now.
Frank Lemanschik
@frank-dspeed
Dec 01 2017 15:06
i have a issue where i need some people that can code canjs
and finish projects
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:08
for some reason, it thinks the view.canEdit value is changing and its re-rendering the stache partial
Kevin Phillips
@phillipskevin
Dec 01 2017 15:09
what is view.canEdit?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:09
Even in the debugger helper if I call get('view.canEdit') it results in maximum call stack error
view.canEdit should be true
If I do get('view').canEdit the value is true
Kevin Phillips
@phillipskevin
Dec 01 2017 15:10
what is view?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:10
but if I do get('view.canEdit') the recursion happens
Kevin Phillips
@phillipskevin
Dec 01 2017 15:10
ok
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:10
view is a DefineMap
Kevin Phillips
@phillipskevin
Dec 01 2017 15:11
ok
can you put a breakpoint in can-view-scope's read function
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:13
Yep. I am walking through the view.canEdit now. What should I look for?
KeyInfo is all false values
Kevin Phillips
@phillipskevin
Dec 01 2017 15:20
um, it's hard to say what to look for... that's what should be looping though
how is canEdit defined?
is it a getter or anything like that?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:21
No, I'm just creating an object view. and passing it to a component using view:from
Kevin Phillips
@phillipskevin
Dec 01 2017 15:37
ok
any luck finding why the recursion is happening in read?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:38
in _read data.value is always undefined
so it gets pushed into undefinedObserves
and I think it looks it up in a parent scope
Kevin Phillips
@phillipskevin
Dec 01 2017 15:40
what is it trying to read?
what is the context... and keyReads
Frank Lemanschik
@frank-dspeed
Dec 01 2017 15:41
@phillipskevin wouldn't that be a great test for 4.0?
i think its made for exact such cases?
Kevin Phillips
@phillipskevin
Dec 01 2017 15:42
what?
Frank Lemanschik
@frank-dspeed
Dec 01 2017 15:42
the better debug output could show
why it is undefined
Kevin Phillips
@phillipskevin
Dec 01 2017 15:42
oh, sure
any debugging would be better in 4.0
but you can't really upgrade any projects to 4.0 yet
Frank Lemanschik
@frank-dspeed
Dec 01 2017 15:42
why whats blocking?
is there a block list?
Kevin Phillips
@phillipskevin
Dec 01 2017 15:43
getting all the tests passing, mainly
Frank Lemanschik
@frank-dspeed
Dec 01 2017 15:43
in the canjs/canjs repo?
or in the repos of the new components?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:44
keyReads looks correct. Its an array with the view and canEdit
Kevin Phillips
@phillipskevin
Dec 01 2017 15:45
ok
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:46
It switches between helpers, if and view, canEdit
I know that's probably not very helpful
Kevin Phillips
@phillipskevin
Dec 01 2017 15:47
ok, so it's looking for helpers.if and then view.canEdit
repeatedly
so you have
{{#if view.canEdit}}
  ...
{{/if}}
something like that?
I've put a simplified example into a jsbin though and the error doesn't happen...lol
Kevin Phillips
@phillipskevin
Dec 01 2017 15:49
what is that last {{else}} for?
oh, maybe it's right
the indenting is just off I guess
maybe?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:51
I think the indent is off
Kevin Phillips
@phillipskevin
Dec 01 2017 15:52
yeah
ok
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:52
I think I have an idea...I'm just going to remove chunks of the code until it works
Kevin Phillips
@phillipskevin
Dec 01 2017 15:52
{{debugger}}
{{#if view.canEdit}}
  ...
{{/if}}
is that where you had the debugger?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:53
Yep
Kevin Phillips
@phillipskevin
Dec 01 2017 15:54
ok
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:56
Oh man, I got it working
Kevin Phillips
@phillipskevin
Dec 01 2017 15:56
:tada:
That value view.formActions doesn't exist in the view
DefineMap
I removed that and it worked
How?
Frank Lemanschik
@frank-dspeed
Dec 01 2017 15:56
nice collection @roemhildtg
don't knowed that you got a collection of can-components
Kevin Phillips
@phillipskevin
Dec 01 2017 15:57
is formActions set later?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:57
Nope, it was a typo leftover from some stuff
I hadn't noticed it before, because it always worked
Kevin Phillips
@phillipskevin
Dec 01 2017 15:57
ok
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:57
lol
Kevin Phillips
@phillipskevin
Dec 01 2017 15:57
there's still a bug somewhere then
in canjs I mean
Gregg Roemhildt
@roemhildtg
Dec 01 2017 15:58
It even worked in other pages, but for some reason this particular view had issues
Yeah, a really hard to find bug
@frank-dspeed Yeah, I've been working on those for some time now. Needed a good modular data-crud interface
Kevin Phillips
@phillipskevin
Dec 01 2017 15:59
yeah, would love to simplify it and see how 4.0 handles it
Frank Lemanschik
@frank-dspeed
Dec 01 2017 15:59
i will try to use them and contribute
Kevin Phillips
@phillipskevin
Dec 01 2017 15:59
(and also fix the bug in 3.0 of course)
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:00
of course :)
Frank Lemanschik
@frank-dspeed
Dec 01 2017 16:01
does some one know a good point
to debug none existing values?
i mean i sometimes simply set sealed: false
to solve that but would love to know what was missing
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:02
I've run into that before
Frank Lemanschik
@frank-dspeed
Dec 01 2017 16:02
i mean none existing values on define/map
to point that out clear :)
but i think all got it right
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:03
Oh, so you defined a value on the DefineMap, but no value is currently set?
Frank Lemanschik
@frank-dspeed
Dec 01 2017 16:03
no better i defined it in a component
:)
and i am passing it to other components
and the target component don't got that property
its a fail from me but i want to know how to find such values more fast
as when the target define-map gets instanced without sealed false it would error
but with no usefull information
when i do sealed false it works the property gets added
but i am still not knowing what got added or was missing befor
:D
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:05
Oh, gotcha. How are you passing the value to other components?
Frank Lemanschik
@frank-dspeed
Dec 01 2017 16:06
can-route
:D
so its complex
i have many apps
its complex :) thats why i ask if that could not possible be simplyfied
i get data from many sources
in diffrent formarts with diffrent updating filds
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:07
Yeah, I'm in a similar boat. That's why it gets so tough to debug issues like the one I had. I've got routing hooked up to multiple can apps and the problems don't happen in simple examples
Looking forward to 4.0/can-queues for this
Frank Lemanschik
@frank-dspeed
Dec 01 2017 16:09
right
i am running a lot of terminals with that
that get diffrent data from diffrent devices
lets say ATM like Boxes
:D
with card readers and that
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:12
How do I convert {{#each pageData.views as view}} to the new syntax? {{#each(pageData.views view=value)}}?
Frank Lemanschik
@frank-dspeed
Dec 01 2017 16:12
i don't know if a codemod exists :(
chason probally the person who knows what codemods exist
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:13
No, not yet. Justin said there will be one soon with 4.0. But I'm wondering is that the correct new syntax?
Frank Lemanschik
@frank-dspeed
Dec 01 2017 16:13
hmmm i am not sure
i would say without ()
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:14
Its weird, its like I'm passing "view" to each. But I want view to be set as the value
Frank Lemanschik
@frank-dspeed
Dec 01 2017 16:14
so #each pageData.views as view=value
why don't u simply do
{{#pageData.view}}
that would give you inside that this as context
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:15
nvm, its in the docs:
{{#each(todos, todo=value num=index)}}
    <li data-index="{{num}}">{{todo.name}}</li>
{{/each}}
Frank Lemanschik
@frank-dspeed
Dec 01 2017 16:15
ok
cool
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:15
I just like having the value named
Frank Lemanschik
@frank-dspeed
Dec 01 2017 16:15
ya
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:15
Sometimes its a little more obvious
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:29
@frank-dspeed I'd love to collaborate on those components, we can chat here: https://gitter.im/can-admin/Lobby
Kevin Phillips
@phillipskevin
Dec 01 2017 16:32
there must be a codemod somewhere @roemhildtg
I know we didn't update all the docs manually
let me try to find it
Nico R.
@nriesco
Dec 01 2017 16:32
is there a way to do this in canjs: http://knockoutjs.com/documentation/rateLimit-observable.html (see example 2)
What I want is that when you type in an input element you don’t have to wait until you click outside of it
Kevin Phillips
@phillipskevin
Dec 01 2017 16:33
on:input:value:to="foo"
Nico R.
@nriesco
Dec 01 2017 16:33
but of course it needs a “rate limiter” as in the example
Kevin Phillips
@phillipskevin
Dec 01 2017 16:33
you would have to create your own event I think
Nico R.
@nriesco
Dec 01 2017 16:35
I’m still confused with that syntax, is it on:input:value:to=“foo" equal to when dom event input send value to foo?
i use “on:click=…"
but on:value is new to me
Kevin Phillips
@phillipskevin
Dec 01 2017 16:36
so if you do value:to="foo" it will set the foo property to the value of your <input> on a change event
(change events happen on blur... when you click outside the input)
on:input:value:to="foo" will set the foo property to the value of the <input> on input events
so whenever you type a key
Nico R.
@nriesco
Dec 01 2017 16:38
so input is a dom event?
Kevin Phillips
@phillipskevin
Dec 01 2017 16:38
yes
you could do on:keyup:value:to also
or whatever event you want
Nico R.
@nriesco
Dec 01 2017 16:39
Oh I see, input is just new for me...
Nico R.
@nriesco
Dec 01 2017 16:41
cool, so I only need to figure out how to throttle a function and that would work for me, thanks again @phillipskevin
Kevin Phillips
@phillipskevin
Dec 01 2017 16:42
lodash has throttle
you could probably wrap the setter in that
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:44
That's a cool idea. You'd need another value, like isThrottling, though too I think. To opt out of setting the value if the value is currently being set
Kevin Phillips
@phillipskevin
Dec 01 2017 16:45
well... maybe what I would do is create one property that's bound directly to the input value
and another property for the throttled value
I dunno... depends why you want to throttle it
Nico R.
@nriesco
Dec 01 2017 16:50
in my experience with other technologies you need to throttle calls to async data such as an ajax call
or too complex computed / functions
to avoid consuming too much network or cpu
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:52
True that. I think can-connect does some throttling under the hood with one of the behaviors
Nico R.
@nriesco
Dec 01 2017 16:52
probably
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:53
a custom behavior might be another way to go about it
Nico R.
@nriesco
Dec 01 2017 16:54
another question: can I send the current “dom element” as a parameter or bind it? <input this:to=“foo”> => this will be the current stache context not the dom element
I think (not sure) in jquery this would be the dom element (jquery style)
Kevin Phillips
@phillipskevin
Dec 01 2017 16:55
foo is a function?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:55
I think he means set foo to the value of <input> element
Nico R.
@nriesco
Dec 01 2017 16:55
yes it could be <input this:to=“foo(., domelement)>
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:55
oh
Kevin Phillips
@phillipskevin
Dec 01 2017 16:55
scope.element then
you can pass
foo(this, scope.element)
Nico R.
@nriesco
Dec 01 2017 16:56
Nice, I’ll give it a try
Gregg Roemhildt
@roemhildtg
Dec 01 2017 16:56
That is something I've wondered though, can you actually bind the value of foo to the input element?
Not necessarily the value, the element itself so you could do some processing on the element?
Kevin Phillips
@phillipskevin
Dec 01 2017 16:59
I don't think you can actually use a function with this shorthand
(on:input:value:to)
Nico R.
@nriesco
Dec 01 2017 17:00
@roemhildtg you can actually use what @phillipskevin told me: scope.element and then within the function $(theScope).addClass(‘new-class’)
instead of addClass you could do any jquery style manipulation
Kevin Phillips
@phillipskevin
Dec 01 2017 17:00
but you can separate them <input value:from="bar" on:input="foo(scope.element)" />
Nico R.
@nriesco
Dec 01 2017 17:00
is that what you need or something else?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 17:01
There's just been times where I might want the element on the ViewModel so I can do this.inputElement in other parts of the viewmodel
Kevin Phillips
@phillipskevin
Dec 01 2017 17:01
yeah, you can do that
it makes testing a little more difficult
but you can do that in the inserted event of your component
Gregg Roemhildt
@roemhildtg
Dec 01 2017 17:02
I could do something like <input on:inserted="setInputElement(scope.element)">
Kevin Phillips
@phillipskevin
Dec 01 2017 17:02
this.viewModel.element = this.element
yeah, you can
Gregg Roemhildt
@roemhildtg
Dec 01 2017 17:02
But yeah, testing becomes more difficult for sure
Nico R.
@nriesco
Dec 01 2017 17:03
thanks @phillipskevin my code is up and running now, I’ll test throttling later!!
Kevin Phillips
@phillipskevin
Dec 01 2017 17:04
:thumbsup:
to update all Helper expressions ({{#each foos as foo}}) to Call expressions ({{#each(foos, foo=value)}}
Gregg Roemhildt
@roemhildtg
Dec 01 2017 18:29
Ooooh! nice
You can literally do anything with code mods, yeah?
Kevin Phillips
@phillipskevin
Dec 01 2017 18:50
if you're good enough at regex :smile:
which I am not
but some people are
Gregg Roemhildt
@roemhildtg
Dec 01 2017 18:54
hehe, yeah. That's one thing I'd love to dive into in more depth some day...
Frank Lemanschik
@frank-dspeed
Dec 01 2017 18:58
I can do regex
Gregg Roemhildt
@roemhildtg
Dec 01 2017 19:43
@phillipskevin I found another little problem. This time with convertors. I've got a checkbox list like this:
  {{#each properties.options opt=value}}
    <div class="form-group">
      <label class="form-{{#if properties.style}}{{properties.style}}{{else}}checkbox{{/if}}">
        <input type="checkbox" checked:bind="boolean-to-inList(opt.value, root.value)" on:el:change="onChange" />
        <i class="form-icon"></i> {{opt.label}}
    </label>
    </div>
  {{/each}}
But the list value never changes, and the checkboxes are not checkable
Like they don't actually toggle
If I remove the boolean-to-inList the checkbox does toggle when clicked
Kevin Phillips
@phillipskevin
Dec 01 2017 19:44
is opt.value a compute?
you normally need ~opt.value
Gregg Roemhildt
@roemhildtg
Dec 01 2017 19:45
properties.options is like this:
[{ label: 'string', value: 'string' } ...]
Kevin Phillips
@phillipskevin
Dec 01 2017 19:45
oh, maybe you don't with boolean-to-inList
Gregg Roemhildt
@roemhildtg
Dec 01 2017 19:45
I'll try the tilda
That didn't change
Gregg Roemhildt
@roemhildtg
Dec 01 2017 19:51
The weird thing is that the get/set in the converter are not being called
Gregg Roemhildt
@roemhildtg
Dec 01 2017 20:05
This is sort of what I'm trying to do...although the jsbin isn't currently working for some reason "can't observe value change"
Gregg Roemhildt
@roemhildtg
Dec 01 2017 20:27
I don't know whats wrong again lol. I got the jsbin working and of course it works perfectly.
Kevin Phillips
@phillipskevin
Dec 01 2017 20:29
maybe it's something we fixed?
are you on the latest?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 20:42
I believe so, yes. 3.3.0 for can-view-converters
Kevin Phillips
@phillipskevin
Dec 01 2017 20:45
you can just run npm outdated
and see if any can-* packages show up
Gregg Roemhildt
@roemhildtg
Dec 01 2017 20:50
can-assign      1.0.1    1.1.1    1.1.1  can-navigate
can-connect    1.5.10   1.5.10   1.5.12  can-navigate
can-reflect     1.7.3    1.7.3   1.10.2  can-navigate
can-stache     3.13.2   3.13.2   3.14.2  can-navigate
can-util      3.10.15  3.10.15  3.10.17  can-navigate
looks like i can update can-stache and can-reflect
btw, cool tip
npm outdated
Kevin Phillips
@phillipskevin
Dec 01 2017 20:52
we'd never release a new version of canjs without it
:wink:
Gregg Roemhildt
@roemhildtg
Dec 01 2017 20:55
Yeah, I bet. :tired_face:
Gregg Roemhildt
@roemhildtg
Dec 01 2017 21:23
So...in can-stache/expressions/call I might have found the issue
well, part of it
This line is returning undefined
Kevin Phillips
@phillipskevin
Dec 01 2017 21:25
what is method ?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 21:26
image.png
method is the scopeKeyData and can-reflect appears to not find a function for that
Kevin Phillips
@phillipskevin
Dec 01 2017 21:27
question I should have asked initially... have you imported can-stache-converters?
Gregg Roemhildt
@roemhildtg
Dec 01 2017 21:27
Yep I do have it imported
I've missed that one before ;)
Kevin Phillips
@phillipskevin
Dec 01 2017 21:29
ok
i'll try it
Kevin Phillips
@phillipskevin
Dec 01 2017 21:35
ok, a basic example works
Gregg Roemhildt
@roemhildtg
Dec 01 2017 21:36
Yep
I tried an even more complex example here:
Kevin Phillips
@phillipskevin
Dec 01 2017 21:36
yeah... I just wanted to make sure the latest versions worked
which aren't part of can.all
you should see it try to look up "boolean-to-inList"
and it should find it inside helpers
can you do me a favor and run npm ls can-stache in your terminal
Gregg Roemhildt
@roemhildtg
Dec 01 2017 21:40
+-- can-admin@0.2.0 (github:roemhildtg/can-admin#dd3a69aba6036848007db3fe09deed85ebe50d53)
| `-- can-stache@3.13.2  deduped
+-- can-arcgis@1.0.0 (github:roemhildtg/can-arcgis#0c9f4a2461bd591dcb25527e393cc3d43a70b4d9)
| `-- can-stache@3.13.2  deduped
+-- can-component@3.3.6
| `-- can-stache-bindings@3.11.3
|   `-- can-stache@3.14.2
+-- can-connect@1.5.10
| `-- can-stache@3.13.2  deduped
+-- can-stache@3.13.2
+-- can-stache-converters@3.3.0
| `-- can-stache@3.13.2  deduped
+-- documentjs@0.5.1
| `-- can-stache@3.13.2  deduped
`-- steal-stache@3.1.3
  +-- can-stache@3.13.2  deduped
  `-- can-view-import@3.2.5
    `-- can-stache@3.13.2  deduped
I'm going to try upgrading to 3.14
Kevin Phillips
@phillipskevin
Dec 01 2017 21:42
ok
Gregg Roemhildt
@roemhildtg
Dec 01 2017 21:44
Okay. That got it working now. :confetti_ball:
Kevin Phillips
@phillipskevin
Dec 01 2017 21:44
ok
so this is a bug in stache
Gregg Roemhildt
@roemhildtg
Dec 01 2017 21:45
lol. I feel like I wasted a lot of your time. I'm sorry I didn't realize it wasn't on the latest version
Kevin Phillips
@phillipskevin
Dec 01 2017 21:45
i'll open an issue
it wasted a lot of your time too :frowning:
Gregg Roemhildt
@roemhildtg
Dec 01 2017 21:47
meh, its friday. I'm about 30 minutes from the weekend :)
Kevin Phillips
@phillipskevin
Dec 01 2017 21:49
:smile:
Gregg Roemhildt
@roemhildtg
Dec 01 2017 21:55
:beers: Thanks for the help
Kevin Phillips
@phillipskevin
Dec 01 2017 21:58
glad you figured it out
we'll add an error to prevent other people from spending hours tracking this same thing down
Gregg Roemhildt
@roemhildtg
Dec 01 2017 22:00
That will be helpful