Epps!

User Store

This page is an example of how to create a store representing a user. The store called useUserStore and uses deep inheritance to benefit from the state and methods of several parent stores.

User Store creation

This store inherits from the useContactStore, which in turn inherits from the useItemStore.

In addition, the Store extends the setData method also declared in the parent Store useItemStore. For the setData method to be extended, it must be declared in the extendedState.options.actionsToExtends parameter.

The store is also persisted every time its state is modified, thanks to the extendedState.options.watchMutation option, and sensitive data is encrypted thanks to the extendedState.options.persist.persistedPropertiesToEncrypt option (see localStorage "connectedUser" key).

Uses the extendedState function to obtain default and required state properties for the plugin.

See extendedState function documentation

@see

For more information on parent stores extended by useUserStore : Github repo

Use User Store

We create an instance of the user store using useUserStore and type it with the appropriate methods and state.

Set data

Use setData method to set or update user data.