These are chat archives for canjs/canjs

6th
Apr 2015
Marshall Thompson
@marshallswain
Apr 06 2015 05:19
I'm not sure if this will be useful to you, but It works great for me: Using the new Steal with NPM, if you are loading from a URL you don't have to directly import Stache. You can just do...
var template = require('./template.stache!') then use it in a can.view right away. Steal takes care of the rest.
Alex
@whitecolor
Apr 06 2015 08:18
Some of my components (most actually) take template: 'template string';, so I want them to be treated as stache without explicitly template: can.stache('template string');But by default this template strings convert to mustache inside can.component constructor.
Matthew Phillips
@matthewp
Apr 06 2015 12:07
There isn't a way to change what Component uses for template strings. Maybe in 3.0 we can change it
But it's easy enough to do: template: can.stache('template string') instead.
Justin Meyer
@justinbmeyer
Apr 06 2015 15:46
CanJS 2.2 release: http://blog.bitovi.com/canjs-2-2/ Please share it on the social medias :-)
Matthew Phillips
@matthewp
Apr 06 2015 18:00
woot!
Justin Meyer
@justinbmeyer
Apr 06 2015 19:53
@dylanrtt hello
you were talking about the batching changes causing problems for your app
and I asked what problem you were seeing
if it is an infinite loop
dylanrtt
@dylanrtt
Apr 06 2015 19:54
@justinbmeyer the issue is not an infinite loop, it just seems to be firing off an event at the wrong time... not sure what more I can say because there is a huge call stack and all kinds of spaghetti involved
Justin Meyer
@justinbmeyer
Apr 06 2015 19:55
yeah, events can no longer preempt already queued events
so that can.batch. afterPreviousEvents can help for situations like this
@whitecolor arg ... we should have had an option available to change that for 2.2
dylanrtt
@dylanrtt
Apr 06 2015 19:57
strangely, the event handler that was a problem wouldn't run in 2.2.0 in that situation but it would run in 2.2.1... so maybe the ordering change caused some other side effects in my app due to the app being written poorly
Justin Meyer
@justinbmeyer
Apr 06 2015 19:58
I'd support an issue for a way to toggle what engine template: "STRING" uses by default
well, lookout for those "office hours" and we can probably help you
we can sign NDAs and such if you need that approved beforehand
@dylanrtt regarding your can.view() and StealJS issue
I would throw an error if anyone is using can.view
and that will help you identify them all pretty quickly
even if there's 100
you can probably fix on a min and it will only take you 2 hrs
dylanrtt
@dylanrtt
Apr 06 2015 20:05
isn't can.view() called internally though?
Justin Meyer
@justinbmeyer
Apr 06 2015 20:16
not anymore
well, not at least by stealjs
is what stealjs uses to process stache templates
that does not call can.view
dylanrtt
@dylanrtt
Apr 06 2015 21:08
previously, I could do $el.before('stuff.mustache', {}, callback). what is the conversion if I replace the template id with a renderer? it seems to treat my callback as something else... do I no longer need a callback because it's synchronous?
Justin Meyer
@justinbmeyer
Apr 06 2015 21:09
yeah, no callback needed
$el.before( renderer({})
)
Alex
@whitecolor
Apr 06 2015 21:11
@justinbmeyer what about default rendering enging change? Is there an issue on this?
Justin Meyer
@justinbmeyer
Apr 06 2015 21:18
there is not
please create one and we can probably get this in 2.3 (or 3.0 if we don't do 2.3)
Kyle Gifford
@kylegifford
Apr 06 2015 22:56
is there a way to use the define plugin to define properties of an object in a component?
for example, if I had a component with an "appState" property, how could I use the define plugin to define the "currentId" property of appState?
Justin Meyer
@justinbmeyer
Apr 06 2015 23:29
not sure you would want to do that
@kylegifford
normally, it's best with an object defines its own behavior
why are you wanting to do this?
I could see that appState / can.route is sorta of an exception ... because there are different properties that impact different parts of the app
so you might want to define the behaviors of those properties for just that part of the app
but, you couldn't test app-state
independent of those components
which creates another problem
Julian
@pYr0x
Apr 06 2015 23:30
hi justin
Justin Meyer
@justinbmeyer
Apr 06 2015 23:31
hello
Julian
@pYr0x
Apr 06 2015 23:32
i talked to matthew
he told me, if i want to use the downloaded custom version
i must use the shim config in requirejs
i did
but i get the same error
as #1605
there is a request for can/view/stache/stache
and i dont know why
Justin Meyer
@justinbmeyer
Apr 06 2015 23:35
I don't know what you mean by "request"?
are you using the custom version within an AMD app?
@pYr0x Yeah, that's fine. You shouldn't use the download with requirejs.
regarding that
a person should use the AMD version of CanJS within an AMD application
not the download builder version
the difference is the download builder version is only intended to be used in a "global" setting ... not within an AMD environment
cc @matthewp
we can probably figure out a way to make it work in an AMD environment
but it's not super high priority b/c we expect people to use the AMD version for this situation
Matthew Phillips
@matthewp
Apr 06 2015 23:38
Its a global and requirejs has shim configuration so that's the answer if you really must use the glo al.
Julian
@pYr0x
Apr 06 2015 23:39
sorry... dont understand
shim: {
can: {
deps: ['jquery'],
exports: 'can'
}
}
is my shim for canjs (custom version)
Justin Meyer
@justinbmeyer
Apr 06 2015 23:40
don't use the custom version
use the AMD version
Julian
@pYr0x
Apr 06 2015 23:41
yes, but thats not the point
Justin Meyer
@justinbmeyer
Apr 06 2015 23:41
Using the non AMD version in an AMD application is not supported
so, it kinda is the point :-)
Julian
@pYr0x
Apr 06 2015 23:42
so but i can shim the non amd version
and i should work?
Justin Meyer
@justinbmeyer
Apr 06 2015 23:42
It might, it might not
Matthew Phillips
@matthewp
Apr 06 2015 23:42
That shim should work.
You're also using autorender which is another matter
So you'll need to also shim can/view/stache
Justin Meyer
@justinbmeyer
Apr 06 2015 23:43
why can't you use the AMD version?
Matthew Phillips
@matthewp
Apr 06 2015 23:43
exports: "can.stache"
Julian
@pYr0x
Apr 06 2015 23:43
because i want to cache the files with php
Matthew Phillips
@matthewp
Apr 06 2015 23:43
But yes, it's craziness to use the global
Justin Meyer
@justinbmeyer
Apr 06 2015 23:44
can't you do a build with r.js?
and cache the entire build?
Julian
@pYr0x
Apr 06 2015 23:44
because i have not a single app
Matthew Phillips
@matthewp
Apr 06 2015 23:44
Ah
Julian
@pYr0x
Apr 06 2015 23:44
its a multipage app
Justin Meyer
@justinbmeyer
Apr 06 2015 23:44
doesn't r.js let you build your own bundles?
Matthew Phillips
@matthewp
Apr 06 2015 23:44
You should use StealJS then
Justin Meyer
@justinbmeyer
Apr 06 2015 23:45
can you use it to build a custom canjs bundle?
Julian
@pYr0x
Apr 06 2015 23:45
and this is different as the custom version?
Justin Meyer
@justinbmeyer
Apr 06 2015 23:45
well, r.js will build it right
Julian
@pYr0x
Apr 06 2015 23:45
;)
Justin Meyer
@justinbmeyer
Apr 06 2015 23:46
to be used by requirejs
having our custom downloads be useful in an AMD setting isn't a design goal
of the download builder
but that is the design of the AMD export
however, I'm not opposed to making that work
Matthew Phillips
@matthewp
Apr 06 2015 23:47
Steal solves the multi-page caching problem. Can even use your existing and code.
Justin Meyer
@justinbmeyer
Apr 06 2015 23:47
making the download builder do what you need
It's just not a priority, b/c we have a version of CanJS that works in an AMD setting .. that r.js can use to make a custom AMD bundle.
Julian
@pYr0x
Apr 06 2015 23:47
ok
@matthewp so do you have an example?
Justin Meyer
@justinbmeyer
Apr 06 2015 23:48
we might be able to make the download builder produce a "pure" UMD form
Julian
@pYr0x
Apr 06 2015 23:48
thats might be good
Matthew Phillips
@matthewp
Apr 06 2015 23:48
@pYr0x watch the video on StealJS.com
Justin Meyer
@justinbmeyer
Apr 06 2015 23:49
https://github.com/canjs/steal-can-example did a little of this, but needs to be updated
to the latest stealjs
Julian
@pYr0x
Apr 06 2015 23:50
but with stealjs
there also more than 1 request
i want one file caches all the files for this page
Matthew Phillips
@matthewp
Apr 06 2015 23:50
There's exactly the right number of requests
Julian
@pYr0x
Apr 06 2015 23:51
but how can i manage my javascript code with php
Justin Meyer
@justinbmeyer
Apr 06 2015 23:51
you shouldn't manage your JS with PHP :-)
Julian
@pYr0x
Apr 06 2015 23:51
i didnt have node installed on my webserver
Justin Meyer
@justinbmeyer
Apr 06 2015 23:52
you only need to run node to build
so you could checkin the production files
Julian
@pYr0x
Apr 06 2015 23:52
yes but than i have to uploaded all the built files
at my current pojects, all js files are cached by php
Justin Meyer
@justinbmeyer
Apr 06 2015 23:53
what do you mean cached btw?
files are cached by the browser
Julian
@pYr0x
Apr 06 2015 23:53
so i have nothing to do, expect to upload the source files and php do the rest,
Justin Meyer
@justinbmeyer
Apr 06 2015 23:53
so do you mean php is putting response headers in place or something?
Julian
@pYr0x
Apr 06 2015 23:53
no they a cached in a single file
Justin Meyer
@justinbmeyer
Apr 06 2015 23:53
oh, so you have a build script
well, php is concating everything
Julian
@pYr0x
Apr 06 2015 23:54
yes
not everything
the js files they a needed for this page
i would say $this->js = array(......);
and put all the files in there
so today i manged my files in php
Justin Meyer
@justinbmeyer
Apr 06 2015 23:55
ah, so that will be slower than what StealJS does ... which allows caching between pages
Julian
@pYr0x
Apr 06 2015 23:55
yes
Justin Meyer
@justinbmeyer
Apr 06 2015 23:55
(and multiple parallel requests)
Julian
@pYr0x
Apr 06 2015 23:55
thats right
but so i need a built script in node
Justin Meyer
@justinbmeyer
Apr 06 2015 23:55
but why are you using AMD?
Julian
@pYr0x
Apr 06 2015 23:56
my idea is to recieve all the js request on one page
on php
and put them together
Justin Meyer
@justinbmeyer
Apr 06 2015 23:56
but you need the module name in the define
Julian
@pYr0x
Apr 06 2015 23:57
concate them an cache them
Justin Meyer
@justinbmeyer
Apr 06 2015 23:57
does every module you use do that?
Julian
@pYr0x
Apr 06 2015 23:57
yes,, i have to run one time r.js
Justin Meyer
@justinbmeyer
Apr 06 2015 23:57
define("SOMETHING", [], function(){})
ah
Julian
@pYr0x
Apr 06 2015 23:57
i have no better solution
Justin Meyer
@justinbmeyer
Apr 06 2015 23:57
so you do run either Java (rhino) or Node
Julian
@pYr0x
Apr 06 2015 23:57
node on my local machine
Justin Meyer
@justinbmeyer
Apr 06 2015 23:58
and then check in the file r.js built
Julian
@pYr0x
Apr 06 2015 23:58
but thats no realy good
because i have to use node
Justin Meyer
@justinbmeyer
Apr 06 2015 23:58
can you get a server that supports node?
b/c that's how everything is going these days
from the perspective of the front end
Julian
@pYr0x
Apr 06 2015 23:59
yes, but my php framework is designed to run on server with php only
js minify and css minify is also done in php
Justin Meyer
@justinbmeyer
Apr 06 2015 23:59
could you create a build server?
that does the building in node