These are chat archives for canjs/canjs

15th
Feb 2016
Guido Smeets
@gsmeets
Feb 15 2016 13:15
I ran into something annoying just now, wonder if that can be fixed somehow.
When I have a setter defined which throws an exception (in this case, I forgot to declare a dependency I was using), and that setter gets called in the pipeline of a findOne or findAll request, my error is completely swallowed, but randomly other components suddenly fail
Anyone got any ideas?
@abalmush is can.html actually defined? it's not a standard function of canjs
Andrei Balmus
@abalmush
Feb 15 2016 14:09
Hi @gsmeets I didnt included canjs globally to the page. I used it as a dependency in my modules. like var can = require(“can”);
so it is not in global scope
Guido Smeets
@gsmeets
Feb 15 2016 14:10
yeah, I get that. But that html function, do you require that as well?
so it's placed onto the can object
Andrei Balmus
@abalmush
Feb 15 2016 14:12
tried this, webpack shows me that it cant find this dependency
Guido Smeets
@gsmeets
Feb 15 2016 14:12
I think @daffl is the author of can compile, maybe he can help you out
Andrei Balmus
@abalmush
Feb 15 2016 14:12
tried this paths require(‘can/html’), require(‘can/view/html’)
Guido Smeets
@gsmeets
Feb 15 2016 14:12
I think he's in the US, so he should be waking up soon :)
Andrei Balmus
@abalmush
Feb 15 2016 14:13
and I dont see html.js in /dist/cjs
Guido Smeets
@gsmeets
Feb 15 2016 14:14
yeah, that's what I'm trying to tell you, I don't think that's part of canjs
so it must be something can-compile adds
Andrei Balmus
@abalmush
Feb 15 2016 14:47
@gsmeets, can I use other libraris to precompile my templates? Like hogan.js? I mean I know that steal.js make it much easier but we use webpack and I dont want to refactor all this shit ))
Kevin Phillips
@phillipskevin
Feb 15 2016 15:42
@abalmush not sure if this is what you’re looking for, but you can check out can.view.preload
the docs are a little sparse
Guido Smeets
@gsmeets
Feb 15 2016 15:54
I rolled my own version on top of requirejs, so I'm unfamiliar with other tooling out there. In essence what you need is to call can.view.preload with a properly formatted identifier (I.e. the one your regular stack would be requesting)
David Luecke
@daffl
Feb 15 2016 18:51
@abalmush What does can.html do? I'm pretty sure it is not a valid view engine.
Dovid Bleier
@dbleier
Feb 15 2016 21:34
I am using super-map
```

export const signConnection = superMap({
  url: config.attr('env').domain+'get/1',
  idProp: 'id',
  Map: Sign,
  List: Sign.List,
  name: 'sign'
});
    signPromise: {
      get() {
        return Sign.getList({mac: config.attr('mac'), user: config.attr('user')});
      }
    },
    sign: {
      get(last, set) {
        var self = this;
        return this.attr('signPromise').then(function(s, onFullfilled) {
this returns what is in the localstorage cache, just as it should ;)
and I see the cache getting updated with updates from the server, like it should :)
but, after the cache is updated, it's not recomputing sign with the updates :worried:
what am I missing?
dylanrtt
@dylanrtt
Feb 15 2016 21:50
@dbleier I don't think it's supposed to. I think the updates are applied directly to the original results.
Dovid Bleier
@dbleier
Feb 15 2016 22:40
@dylanrtt what do you mean to the original results? the template should render from the previously cached version and then when the new data comes in, shouldn't it update?
dylanrtt
@dylanrtt
Feb 15 2016 22:41
yes, the template should observe the changes
Dovid Bleier
@dbleier
Feb 15 2016 22:41
I don't have a direct relationship between the data and the template, I do some post processing before sending to the template
since the template only shows a fraction of the data
so I need a way of triggering the post processing
dylanrtt
@dylanrtt
Feb 15 2016 22:45
In your reponse callback, you could bind to the original response and update the output upon changes
Dovid Bleier
@dbleier
Feb 15 2016 22:46
I don't quite follow. Can you give an example?
maybe something like that
Dovid Bleier
@dbleier
Feb 15 2016 22:47
ok, I'll try that. thanks
Object.observe is es6?
dylanrtt
@dylanrtt
Feb 15 2016 22:48
yeah, probably not the best example
I think Object.observe was scrapped recently... guessing the example needs updating or maybe it's using a polyfill
Dovid Bleier
@dbleier
Feb 15 2016 22:50
that's what I was guessing. So you recommend just using the standard todos.bind() syntax?
dylanrtt
@dylanrtt
Feb 15 2016 22:51
yeah, but the tricky part will be finding the right place to unbind it so you don't have a memory leak
Dovid Bleier
@dbleier
Feb 15 2016 22:51
aha
dylanrtt
@dylanrtt
Feb 15 2016 22:52
some methods like filter() on can.List should already observe some changes so that might work for you as well
Dovid Bleier
@dbleier
Feb 15 2016 22:52
well, "sign" shouldn't get deleted for the duration of the session, so I don't think it should be a problem
ok, I'll look into that as well
dylanrtt
@dylanrtt
Feb 15 2016 22:55
what kind of post-processing are you doing? if you are just making the output smaller, there's probably very little benefit to doing so
Dovid Bleier
@dbleier
Feb 15 2016 22:57
no, it's reorganizing some of the data for rendering, since the format of the data on the server does not exactly match the format of the data being displayed
also the data being received is a super-set of data, to be displayed at different times, and also some scheduling data is sent
a major requirement is to be able to run offline, so it needs to get everything in one go, so it can continue to run offline
this app is running in a specialized device, not a standard browser
dylanrtt
@dylanrtt
Feb 15 2016 23:02
can-connect is pretty flexible, so you could also create a behavior to make it do what you want, but I don't use it enough to have a good example besides what's already on the main docs page
Dovid Bleier
@dbleier
Feb 15 2016 23:04
yeah, I had thought about using a custom behavior or overwriting hydrateInstance, so something like that. I may still end up doing that if these other ideas don't work
dylanrtt
@dylanrtt
Feb 15 2016 23:09
some transformations could be performed in getters defined in your Map. For instance, if you want to use map.attr('foo') in your template, foo could be a virtual property that is derived from the data in its raw format... setters would probably also work