ember-api-actions icon indicating copy to clipboard operation
ember-api-actions copied to clipboard

Add Decorator Support

Open alexlafroscia opened this issue 5 years ago • 21 comments
trafficstars

This adds two decorators, memberAction and collectionAction, that are exported from ember-api-actions/decorators. They are built to be compatible with the V1 decorator spec.

The exported functions are called with the same options as the existing helpers, and internally call the exact same logic.

Open Questions:

  • [x] Is it worthwhile to modify the existing functions instead to detect usage as a decorator, as to avoid exporting a second set of helper methods?
  • [x] Should the documentation be updated to default to the decorator-based usage?

Left To-Do, Pending Question Resolution:

  • [x] Add documentation about decorator usage

Closes #413

alexlafroscia avatar Apr 05 '20 18:04 alexlafroscia

@dbollinger I'd love to get your thoughts on the "open questions" above -- especially whether we should detect usage inside one version of memberAction and collectionAction or keep them as two separate imports that are designed for specific purposes.

alexlafroscia avatar Apr 06 '20 14:04 alexlafroscia

This is great!

For question 1 -- I generally favor the advice to "prefer duplication over the wrong abstraction" and in this case a separate export seems fine. Alpha/beta releases can help make that a smoother process as well.

For question 2 -- I think some additive documentation would be a good first step, but I'm not sure about the best way to manage that alongside the release process.

dbollinger avatar Apr 06 '20 17:04 dbollinger

prefer duplication over the wrong abstraction

Good words to live by! I’m cool with making it a separate import right now and maybe combining them sometimes in the future. This package is technically still pre-1.0.0, so the API can break before an official 1.0.0 release if it needs to!

Given the fact that it won’t be the exports from the “main” module, I’ll add some README documentation to for the decorator usage rather than updating the existing documentation to use the new flavor.

alexlafroscia avatar Apr 06 '20 23:04 alexlafroscia

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@ff24733). Click here to learn what that means. The diff coverage is n/a.

codecov[bot] avatar Apr 07 '20 15:04 codecov[bot]

Rebased to use setupPretender again

alexlafroscia avatar Apr 09 '20 16:04 alexlafroscia

Hmm... So it seems like the decorator tests don't working for Ember... 2.16 and 2.18.

Some thoughts:

  • Should we bother with those Ember versions at all? We could raise the minimum version run against to the most recent LTS going forward
  • We could just skip the decorator tests for these old Ember versions

alexlafroscia avatar Apr 09 '20 18:04 alexlafroscia

Hmm... So it seems like the decorator tests don't working for Ember... 2.16 and 2.18.

Some thoughts:

  • Should we bother with those Ember versions at all? We could raise the minimum version run against to the most recent LTS going forward
  • We could just skip the decorator tests for these old Ember versions

Will decorators work in those versions anyways? 🤷‍♂️

emilkarl avatar Apr 16 '20 06:04 emilkarl

Will decorators work in those versions anyways? 🤷‍♂️

They could -- the original implementation of the decorator I had did -- but the way it is not implemented, where TypeScript's compiler is satisfied, does not.

I would be in favor of just dropping support for these two very old Ember versions and increase the minimum version to 3.12. I will address that in a separate PR and we can discuss the idea more there.

alexlafroscia avatar Apr 16 '20 14:04 alexlafroscia

@mike-north @alexlafroscia do we know what's the status here 🙏

esbanarango avatar Jan 21 '21 18:01 esbanarango

No updates from me 🤷‍♂️ I honestly forgot I made these PRs, but with the update-to-Ember-3.12-at-a-minimum PR still standing as it is, I don't think we're in a place to move forward really.

alexlafroscia avatar Jan 22 '21 15:01 alexlafroscia

Looks like that Pr landed so this PR can move forward? I think the prototype workaround is alright but decorators would also be nice!

ducharmemp avatar May 26 '21 18:05 ducharmemp

Is there any news on this? Would indeed be nice to have this in.

MarcoKramer avatar Nov 23 '21 11:11 MarcoKramer

@alexlafroscia Possible we could rebase with the latest on the main branch and see if @Turbo87 would be open to merging and releasing it?

snewcomer avatar Dec 03 '21 21:12 snewcomer

That would be 🔝 @alexlafroscia @snewcomer !! Thank you for putting this together 🙏

esbanarango avatar Dec 03 '21 21:12 esbanarango

@snewcomer Did the rebase and made a new PR which is here: #609

jkeen avatar Nov 21 '22 18:11 jkeen

FWIW we (@mainmatter) forked the addon and created a new API that does not involve decorators at all but should also be a bit more TS friendly once we add types: https://github.com/mainmatter/ember-api-actions

Turbo87 avatar Nov 21 '22 20:11 Turbo87

also, even if we merged this PR we still couldn't release it, because @mike-north still hasn't given anyone npm ownership of the package... :-/

Turbo87 avatar Nov 21 '22 20:11 Turbo87

@Turbo87 Thanks for forking and taking over! I hate it when this happens to great projects (and great PRs) and there's no clear passing of the torch.

Your solution feels great, and I'm gonna migrate over to that and forget about this branch entirely! 🎉

jkeen avatar Nov 21 '22 22:11 jkeen

@mike-north Pssssst think you could pass the keys over to someone else and archive this repo, maybe updating the readme with a link to the maintained project? Seems like you're not into this project anymore and it'd be great to give the community a direction to go towards.

jkeen avatar Nov 21 '22 22:11 jkeen

In trying to use your version @Turbo87, it looks like…

a) it's not actually a fork of this project but a completely new project with the same name? If you're looking to carry this project forward into the future (and I hope you are!), it feels weird to not have the years of git history that came before. If this were my project that I started and then abandoned, I'd feel slighted if my name were erased from the history.

b) Your addon seems to be missing some key features that this one has, like the before and after hooks on the actions. Was that intentional?

jkeen avatar Nov 22 '22 02:11 jkeen

it doesn't have the history because we've rewritten it from scratch with a completely different API 😅

yes, before and after missing is intentional, because you can just do those before and after the action call within the async function.

also, I apologize for the lack of documentation so far. it's still work in progress, but I thought I'd share it here already anyway :)

Turbo87 avatar Nov 22 '22 07:11 Turbo87