You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Allow composition of computed decorators #4
importEmberObjectfrom'ember-object';importcomputed,{or}from'ember-computed-decorators';exportdefaultEmberObject.extend({
@computed @or('bar','qux')// or @computed(or(..))foo(barOrQux){}});
It actually turned out that composable macros were upstreamed to Ember quite a while ago, and then reverted. I believe this was in the v1 era, @twokul was the person who worked on it so he may have more context.
I think based on that, this will probably make sense more as an external library. I also think that based on the direction of @tracked, it would make sense as a non-Ember-specific library of macro decorators that don't have caching, and would actually be much simpler. So you would basically be able to do:
Note that I'm using the functional/nested syntax now (@sum(mapBy(...)) instead of @sum @mapBy(...)) because I think it'll scale better as more decorators become available, otherwise it becomes confusing which decorators relate and which do not, etc.
Activity
pzuraq commentedon Feb 23, 2018
I feel like this should probably be upstreamed to Ember actually, but I think we can support it in the syntax for this macro
lolmaus commentedon Dec 27, 2018
Any ideas? Not being able to compose macros is a major setback for me.
CC @wycats @rwjblue
pzuraq commentedon Dec 28, 2018
It actually turned out that composable macros were upstreamed to Ember quite a while ago, and then reverted. I believe this was in the v1 era, @twokul was the person who worked on it so he may have more context.
I think based on that, this will probably make sense more as an external library. I also think that based on the direction of
@tracked, it would make sense as a non-Ember-specific library of macro decorators that don't have caching, and would actually be much simpler. So you would basically be able to do:Note that I'm using the functional/nested syntax now (
@sum(mapBy(...))instead of@sum @mapBy(...)) because I think it'll scale better as more decorators become available, otherwise it becomes confusing which decorators relate and which do not, etc.lolmaus commentedon Dec 30, 2018
This sounds like a great idea, @pzuraq! 👍
I'm only starting to change my mindset towards decorators. Looks like there are many possibilities I'm missing. ^_^
lolmaus commentedon Jan 25, 2019
This works today:
@pzuraq Thank you for the hint!
lolmaus commentedon Jun 5, 2019
With every CP dubbing as a decorator, this is now possible:
It feels SO FREAKING GOOD! Big thanks to @pzuraq and everyone who made it possible! 🙇 🙇 🙇