These are chat archives for canjs/canjs

13th
Mar 2015
Justin Meyer
@justinbmeyer
Mar 13 2015 15:51
@jandjorgensen
?
Matthew Phillips
@matthewp
Mar 13 2015 16:41
@justinbmeyer we should do some hangouts to introduce new 2.2 features
Justin Meyer
@justinbmeyer
Mar 13 2015 16:42
agreed
Matthew Phillips
@matthewp
Mar 13 2015 16:42
I could talk about how to start a project with steal / requirejs / browserify
Justin Meyer
@justinbmeyer
Mar 13 2015 16:42
@daffl :-)
Matthew Phillips
@matthewp
Mar 13 2015 16:42
Chris could talk about the sort plugin
etc.
Justin Meyer
@justinbmeyer
Mar 13 2015 16:42
once the release is out, david will begin his evangelism
Curtis Cummings
@ccummings
Mar 13 2015 18:47
Maybe I’m just being dense, but if I return an Array or Object from a type definition using define shouldn’t they get converted into an Observable?
Justin Meyer
@justinbmeyer
Mar 13 2015 19:58
@daffl There's a batching issue on samsclub
I'm going to get in a fix for it
assuming you haven't tagged
Matthew Phillips
@matthewp
Mar 13 2015 20:00
is that the issue @moschel filed?
Justin Meyer
@justinbmeyer
Mar 13 2015 20:00
yes
there's an issue number?
nm
Matthew Phillips
@matthewp
Mar 13 2015 20:00
bitovi/canjs#1519
Justin Meyer
@justinbmeyer
Mar 13 2015 20:01
yeah
I was pretty worried for a moment about it
but I think I know a good way to make it work
I'm semi surprised we've not noticed it before.
Matthew Phillips
@matthewp
Mar 13 2015 20:04
cool, will be interested in seeing the code
Justin Meyer
@justinbmeyer
Mar 13 2015 20:05
well, here's the test
var ft = can.compute('a');

var propA = can.compute(function(){
    return ft() == 'a';
});

var propB = can.compute(function(){
    return ft() == 'b';
});

var combined = can.compute(function(){
var valA = propA(),
    valB = propB();

    return valA || valB;
});

equal(combined(), true);

console.log('binding to combined');
combined.bind('change', function(){ });

can.batch.start();
ft('b');
can.batch.stop();

equal(combined(), true);
in short, combined() will be false
because when ft updates
it immediately updates propA
which immediately causes combined to re-evaluate
before propB has re-evaluated
the fix is simply to make sure anything triggered within a batch comes at the end of the currently running batch
Matthew Phillips
@matthewp
Mar 13 2015 20:07
but shouldn't combined re-evaluate after propB?
Justin Meyer
@justinbmeyer
Mar 13 2015 20:07
it should, but doesn't
because currently, it sees A change
and immediately re-evals
we need a way to make sure any "initial" responders are notified first, before 2ndary and such
Matthew Phillips
@matthewp
Mar 13 2015 20:09
should it re-eval for each?
or just once?
from that code I would expect twice
Justin Meyer
@justinbmeyer
Mar 13 2015 20:09
well, ideally once
for a batch
and that is what it will do w/ this fix
Matthew Phillips
@matthewp
Mar 13 2015 20:10
awesome
Justin Meyer
@justinbmeyer
Mar 13 2015 20:10
(it was only updating once before)
just at the wrong time
I was afraid I'd have to do some type of "warning" pass
to let things know they are in the process of changing
my guess is this is why many other projects do async
an easyish fix to this problem
Justin Meyer
@justinbmeyer
Mar 13 2015 20:28
bitovi/canjs@76331ea
cc @moschel
Justin Love
@JustinLove
Mar 13 2015 22:59
Is there a good place to post-template-render activate a non-can library in a component, or is that just something you should not do?