-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Feature request: lightweight, non-DOM Vue class for services #7290
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
Comments
You don't need to wait for us to build it 😄 We do offer alternatives to Vuex because we know it doesn't fit everybody's mindset. Other have created different solutions you can use as well (Google At the end, what you want to do is pretty much doable already with just |
Hey @posva, Thanks for reading, and the reply. You're certainly right that this is "doable right now" and I thought this would get short shrift! It wasn't really about the memory to be honest, more about the API and general complexity. I got a weird edge case recently with Vue store / services and essentially broke my app for about 6 hours that severely dented my confidence in Vue stores, which I discovered I wasn't alone in:
Maybe those issues could be solved by themselves, but it struck me that just breaking out the reactivity system would be useful in itself. On a side note, I've recently made a service with Vuex |
Overview
TL;DR This is related to the Store pattern, but is not the Store pattern per-se
So at one end of the data-modelling spectrum we have components and reactive properties. In complex apps, you can have a lot of "extra" functionality on parent components to do things that are "related" to the component's job.
At the other end, we have Vuex, with state, getters, and async actions. If not careful, you can find yourself with a lot of "preparatory" or "related" code in the store.
However, I find myself needing something to be shared across various components, but without the overhead of Vuex (and not needing to be centralised) and and simple, reusable service classes generally fit the bill.
If the service is just dumb (let's say a loader) I can get away with a simple class. However, if the service requires state, or it looks advantageous to move state from several components, say, to the service, then using a
new Vue()
is normally the best way.Using a Vue instance is a great way to:
$store
However, they also come with a bunch of machinery (probably most) that's just not needed:
It would be really nice to be able to break out the simple reactiveness of a Vue component into some kind of precursor that could be used independently of something visual.
What problem does this feature solve?
new Vue()
What does the proposed API look like?
Not sure yet how much of Vue's API would be included (events as well?)
The Vue class itself would then mix-in or extend the Store class.
The text was updated successfully, but these errors were encountered: