These are chat archives for canjs/canjs

15th
Jun 2016
Thomas Sieverding
@Bajix
Jun 15 2016 00:16 UTC
Does can-fixture have any capabilty to set the API domain?
I presume that needs to be manually done
Justin Meyer
@justinbmeyer
Jun 15 2016 02:53 UTC

@Bajix

Simply if it’s not in the store, and you’re calling updateInstance, then emit a newInstance event or something similar

that wouldn't be a good idea
because lets say I requested all items that are "critical" from the server
someone created an issue yesterday
and then labeled it "critical" today
the "created" event shouldn't be fired
however, the instance wouldn't be in the store prior to labeling it "critical"
it existed in the database, it just wasn't in the store
I'm not sure what you mean by set the API domain
Thomas Sieverding
@Bajix
Jun 15 2016 03:11 UTC
@justinbmeyer My setup looks like api.foo.com, assets.foo.com; I would want my fixtures to be against the domain of my API
I haven’t run into a case in which created was relevant, hence my preference for the upsert approach
Aside from the case of a websocket api broadcasting a created event, usually you wouldn’t be able to know that (outside of save)
Adam L Barrett
@BigAB
Jun 15 2016 08:04 UTC
Or is this a bug?
Matthew Phillips
@matthewp
Jun 15 2016 11:26 UTC
@BigAB the callback is a setter, so when you do totalCompute(val) it will be called.
It's not a getter callback
I think this is what you want: https://jsbin.com/yivihecoda/2/edit?js,output
qantourisc
@qantourisc
Jun 15 2016 12:02 UTC
How does one deal with async loading of can.Components ? Wait until they are loaded before calling can.view ?
Matthew Phillips
@matthewp
Jun 15 2016 13:01 UTC
Yes
But also, I wouldn't call can.view
I would call stache directly
qantourisc
@qantourisc
Jun 15 2016 13:19 UTC
Suppose I could also do a {{if windows.comp-name }} but that seems kind of jucky
qantourisc
@qantourisc
Jun 15 2016 14:09 UTC
Well actually it should be can.view.callback._tags then
Dovid Bleier
@dbleier
Jun 15 2016 17:09 UTC
my stache all of a sudden stopped rendering. I see console output that the app is running, just no render. Any ideas how to track down what is holding up the render?
Dovid Bleier
@dbleier
Jun 15 2016 17:18 UTC
I assume it is somehow related to can-wait, but not sure what. This code was working last week
Sunil George
@georgesunil81
Jun 15 2016 17:37 UTC
A quick question - I developed a simple pagination component that helps paginate results. It is a simple one with Next and Previous buttons and has buttons for individual pages. I am able to use the component fine without any issues, but I want it to sync when I use it on the top and bottom of the page. If I include the component again on the bottom of the page, it is disconnected from the one in the top. I want both pagination components to remain in sync at all times. Anything major that I am missing?
Dovid Bleier
@dbleier
Jun 15 2016 17:37 UTC
well, at least one thing that seems to be holding this up is this function
    queueNext: function() {
        var self = this,
        ignoredQNR = Zone.ignore(queueNextRec);
        function queueNextRec() {
            self.attr('logger').trace('in queueNext');
            if(self.attr('isplaying')) {
                self.attr('plugin').prepareNext(self.queuedItem().theurl(), self.attr('plugin').Effect.NONE);
                self.attr('plugin').showNow();
                self.play();
                self.attr('playlist').length > 1 && setTimeout(function() {
                    console.log('queueNext ignore setTimeout', self);
                    ignoredQNR();
                },
                self.queuedItem().duration());
            }
        }
        ignoredQNR();

    },
is there something off in the way I am using Zone.ignore?
Kevin Phillips
@phillipskevin
Jun 15 2016 17:47 UTC
@georgesunil81 you need the components to share a viewModel then
Sunil George
@georgesunil81
Jun 15 2016 17:47 UTC
Oh, that seems like it. I missed on that. Do you have a link to an example that I can look at?
Kevin Phillips
@phillipskevin
Jun 15 2016 17:47 UTC
if both components are in the same template, you can share them using a reference scope: https://canjs.com/docs/can.view.bindings.reference.html
Sunil George
@georgesunil81
Jun 15 2016 18:02 UTC
@phillipskevin do you have an example where components share a viewModel?
Kevin Phillips
@phillipskevin
Jun 15 2016 18:02 UTC
no
I can make one quickly in JSBin
Sunil George
@georgesunil81
Jun 15 2016 18:05 UTC
Please if you can. It will be a great help.
Thanks @phillipskevin
Kevin Phillips
@phillipskevin
Jun 15 2016 18:20 UTC
I’m not actually sure if it’s possible to two-way bind the entire viewmodel to the ref scope
you might have to do individual properties
Matthew Phillips
@matthewp
Jun 15 2016 18:23 UTC
Can't you do: <some-component *ref ></some-component> ?
Kevin Phillips
@phillipskevin
Jun 15 2016 18:24 UTC
yeah
but can you do
<some-component *ref ></some-component>
<some-component *ref ></some-component>
that didn’t seem to work for me
Matthew Phillips
@matthewp
Jun 15 2016 18:25 UTC
two instances?
Kevin Phillips
@phillipskevin
Jun 15 2016 18:25 UTC
yeah, to sync the viewmodel between the two
Matthew Phillips
@matthewp
Jun 15 2016 18:25 UTC
oh, so setting the entire view model?
Kevin Phillips
@phillipskevin
Jun 15 2016 18:25 UTC
right
Matthew Phillips
@matthewp
Jun 15 2016 18:26 UTC
Hm, it might be possible using the function syntax of can.component
maybe something like this
<some-component *ref ></some-component>
<some-component vm="*ref" ></some-component>
and then
can.Component.extend({
  tag: 'some-component',
  viewModel: function(attrs) {
    return attrs.vm;
  }
});
or something like that
might have to play with it,
going to try and create a jsbin
Kevin Phillips
@phillipskevin
Jun 15 2016 18:28 UTC
this only seems to sync the second one
Matthew Phillips
@matthewp
Jun 15 2016 18:29 UTC
well the problem is there's not a way to set the vm in stache
so you have to work around it, that's why I was using the function(){} form of viewmodel
Kevin Phillips
@phillipskevin
Jun 15 2016 18:29 UTC
yeah
that makes sense
Matthew Phillips
@matthewp
Jun 15 2016 18:29 UTC
it would be kind of hacky
Kevin Phillips
@phillipskevin
Jun 15 2016 18:31 UTC
would still be interesting to see
Sunil George
@georgesunil81
Jun 15 2016 19:22 UTC
@phillipskevin , I apologize i am trying to follow the thread. Is there any jsbin that I can look at for a two way sync between components.
Kevin Phillips
@phillipskevin
Jun 15 2016 19:24 UTC
I think you need to sync each property separately
Dovid Bleier
@dbleier
Jun 15 2016 19:26 UTC
anyone have suggestion on why my Zone.ignore function is not working? https://gitter.im/canjs/canjs?at=5761926e7a851b587e6f1f91
Sunil George
@georgesunil81
Jun 15 2016 19:27 UTC
Hmm I see, will do. Thanks @phillipskevin for your help here. This will help me sync up the pagination components I have. Thanks a ton.
Kevin Phillips
@phillipskevin
Jun 15 2016 19:27 UTC
you’re welcome
Dovid Bleier
@dbleier
Jun 15 2016 19:39 UTC
or how about this? I sometimes am getting multiple of this exception
TypeError: Cannot read property 'apply' of undefined at http://localhost:8000/node_modules/can-wait/can-wait.js:80:15 at Task.run (http://localhost:8000/node_modules/can-wait/can-wait.js:229:17) at Request.runTask (http://localhost:8000/node_modules/can-wait/can-wait.js:290:14) at g.canWait (http://localhost:8000/node_modules/can-wait/can-wait.js:29:18)
Dovid Bleier
@dbleier
Jun 15 2016 19:47 UTC
I wonder if Chrome changed something related to how setTimeout works last week (and thus how it works with Zone.ignore and canjs in general) that now causes code that used to work not to. I didn't change the code, but now recursive setTimeouts, even in a Zone.ignore, do not work.
Thomas Sieverding
@Bajix
Jun 15 2016 19:49 UTC
@justinbmeyer The findOne in your algebra example still uses the legacyStore