Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Chris Gomez
@akagomez
Or, rather…
‘{scope} promise’: function () { … }
The reason I mention this is that change events have a lot of overhead. For performance reasons they should be avoided when possible.
espretto
@espretto
i tried that, but still the promise now keep re-evaluating itself, plus i'd prefer a solution without a noop binding
good to know that about change
Chris Gomez
@akagomez
The promise keeps re-evaluating because state goes from pending to resolved on every call to the promise compute.
Since promise is dependent on state, it causes a loop.
espretto
@espretto

it seems the promise's call to attr('state', state)sets up a dependency if i'm not mistaken, anyway.
if you could fix the jsbin to work without binding a noop handler to work correctly i.e.

  • update the state when promise changes and when resolved/rejected
  • update the promise if idKey changes
  • update the model when promise resolves

that would grant me a good night sleep!

Chris Gomez
@akagomez
@espretto Are you really on 2.0.3?
Chris Gomez
@akagomez
@espretto The binding on set seems to be a 2.0.3 bug. If you reference latest, your approach works fine: http://jsbin.com/xahaxugobi/1/edit?html,js,console,output
espretto
@espretto
2.0.3 was what i found in jsbin's list, my bad. the binding on set persists in latest though see here. your solution does work for me, however intercepting the idKey setter kind of defeats the purpose of observables, after all, idKey shouldn't have to know what depends on it at all. i'll call it a day. again thanks for your time and efforts! hope to see you around here soon.
Chris Gomez
@akagomez
@espretto Sorry, I must’ve linked you incorrectly. This is your original code running on latest. It works as I think you’d expect: http://jsbin.com/kimuzenele/3/edit?html,js,console,output
Now, as for this new example. Let me look into it.
Diana Whitten
@hurgleburgler
Should steal-tools be available to install through bower?
Diana Whitten
@hurgleburgler
disregard, gonna ask in the steal room :)
opolyo01
@opolyo01
is stache passes index while iterating over collection or I need to write a helper?
in handlebars I would do this -- tabindex='{{@index}}'
getting NaN with stache
dylanrtt
@dylanrtt
@opolyo01 that should work. perhaps you are iterating over an object instead of a list/array in which case you probably want @key
opolyo01
@opolyo01
nope {{#dimensionList}} .. {{/dimensionList}}
dimensionList --> Array
is it even documented anywhere? http://canjs.com/docs/can.stache.html
I am fiddling with it now and it seems that sometimes I do also get NaN
Chris Gomez
@akagomez
@opolyo01 I can get it to work with the {{#each}}helper: http://jsbin.com/warebexisa/edit?html,js,output
opolyo01
@opolyo01
yep, each works
dylanrtt
@dylanrtt
oh right, I think it is only supposed to work with #each, not with {{#list}}{{/list}}
opolyo01
@opolyo01
ok now please remind me the difference of each vs {{#list}}.. I remember one of them is less efficient
Chris Gomez
@akagomez
I tend to steer clear of the {{#block}} helper anyway. It re-renders the entire list on change vs the {{#each}} helper which makes the fewest # of DOM manipulations necessary for each add or remove.
Adam L Barrett
@BigAB
Where is the best place to put animation type code, like sweeping-in, rolling-out type stuff, in a can-component? The viewModel seems the wrong place. The Events object also seems wrong... so what is the right place? (the-can-way)
dylanrtt
@dylanrtt
@BigAB the can.view.attr page shows making a fade-in-when="{prop}" attribute. you could probably apply the same principle to other animations
http://canjs.com/docs/can.view.attr.html#section_Readingvaluesfromthescope_
Adam L Barrett
@BigAB
@dylanrtt thanks
Julian
@pYr0x
canjs can connect meetup?
or i am too late
Adam L Barrett
@BigAB
@pYr0x got cancelled
Julian
@pYr0x
?
why?
Adam L Barrett
@BigAB
Justins wife had a baby
Julian
@pYr0x
ohh
gratulation ;)
neelbhat88
@neelbhat88
Anyone know the best way to solve this in CanJS? I have multiple components that all need the same function - isLoggedIn() for example. Right now I've needed to copy that function into every component which feels very wrong. My gut reaction was to put that in my main component assuming it acts as a parent to all other components and assuming child components inherit from the parent. But I'm pretty sure those assumptions are not correct. Any tips on how to correctly do this is much appreciated!
dylanrtt
@dylanrtt
@neelbhat88 your child components will inherit their parent scopes by default unless you set leakScope: false in your component definition
a better way, which also works without leaking scope, would be to pass it to the child components
there may also be value in simply extracting the function to an outside service if possible and including it in all of your components that need it
neelbhat88
@neelbhat88
@dylanrtt - Thanks! We haven't set leakScope: false anywhere so let me double check and see why the child was not inheriting from the parent scope. I did just notice that my isLoggedIn was set as a variable on the parent scope and not as a function - maybe that's it? I'll find out. At least knowing that child components should inherit their parent scopes is all I need - I'm sure I'm doing something else wrong then. Thanks again!
Aggelos Karalias
@mehiel
Any ideas why partials with can-value inside do re-render as a whole when the bound value is changing?
I'll try to create a fiddle
dylanrtt
@dylanrtt
@mehiel that might be related to #1759
Aggelos Karalias
@mehiel
yes
Aggelos Karalias
@mehiel
I removed the compute wrapping for now in mustache_core.js:391 to make it work.. but this is a brute force workaround that probably breaks lots of other things..