Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mixin alternatives #349

Open
mcfiredrill opened this issue Apr 24, 2020 · 8 comments
Open

mixin alternatives #349

mcfiredrill opened this issue Apr 24, 2020 · 8 comments

Comments

@mcfiredrill
Copy link

Hi! Thanks for this addon, it's been a great help to my projects.

I was wondering if there was any plan or idea to migrate away from the mixin implementation of the FastBoot adapter, so it could be used with native classes more easily.

https://embermap.github.io/ember-data-storefront/docs/guides/fastboot

@pjcarly
Copy link

pjcarly commented Jun 6, 2020

I'm interested in this as well.

Not only for FastBoot, but all mixins in general.

@ryanto
Copy link
Member

ryanto commented Jun 11, 2020

Yup that would be great! This isn't a high priority for me now since the apps I work on don't need it, but if someone is motivated to make this happen I'll absolutely merge the PR.

@billdami
Copy link

billdami commented Aug 5, 2020

Yeah, this is also very desirable for anyone working in a TypeScript-based ember app, where Ember.Mixin is the devil :D

@pjcarly
Copy link

pjcarly commented Nov 20, 2020

Looking at the explanation of @chriskrycho over at:
https://discuss.emberjs.com/t/best-way-to-replace-mixins/17395/2

This will be a difficult choice, if we want to keep the same functionality as it is working now.
Our best option is class decorators, or rewrite the logic in a more service-oriented way, breaking all the implementations.

@ryanto
Copy link
Member

ryanto commented Nov 20, 2020

Thanks PJ!

We recently released 0.18 of storefront, which only supports Ember 3.12+. Does that help with the class decorators?

Also, I'm okay with releasing a breaking change, especially if it gets us away from mixins. What would it look like if it were service oriented?

@chriskrycho
Copy link

Basically, you would inject a storefront service, instead of injecting the store with storefront methods added to it via mixins. Your storefront service would then inject and delegate to the Ember Data service in much the same way that the existing methods do. It would make for a very straightforward swap in most cases, actually.

That is exactly what I would recommend here, after thinking about it all morning. Should be a clean and easy transition and it actually makes for a pretty simple implementation as well!

@pjcarly
Copy link

pjcarly commented Nov 21, 2020

Yes, I prefer a storefront service as well. it is a lot cleaner (plus I do not like class decorators for reasons described in the forum post).

If we look at the different Mixins, there are:

LoadableStore
Easy, when introducing a new Service "storefront" as described by @chriskrycho above

LoadableModel
Would these methods be best moved to that service as well?
Something like:
this.storefront.modelSideload(model: Model, includesString: string, options: object) : Promise<void> ?

FastbootAdapter
I have no experience with anything regarding Fastboot, could someone elaborate?

@pjcarly
Copy link

pjcarly commented Feb 4, 2022

Perhaps it is an idea to undeprecate the functions in the storefront service for starters?
And add functionality for sideloading?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants