Stateful Services
Learn about stateful services, why we use them, and how they can be implemented in a Vue project.
We'll cover the following
Why do we use stateful services?
We can’t always rely on lifting the state, as we might have data that need to be accessible in many different components. This data might not necessarily be siblings but could be at the top of a component tree or deeply nested. In these cases, we might want to put data outside of the component tree and have components that need the data to consume it directly. A good example is user data. Many applications require a user to register and log in. Besides collecting email, users are often also asked to provide their names. This information can be useful for providing a more personalized experience. For instance, we could display the user’s name in a header and a chat bubble, as shown in the figure given below.
Get hands-on with 1400+ tech skills courses.