question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass pinia options in model

See original GitHub issue

Hi!

I’m currently working on a project in which I have to migrate from Vue2 with Vuex-ORM into Vue3 with Pinia-ORM. One of the requirements of the project is to persist the store during page reloads (which I try to accomplish with the pinia-plugin-persistedstate plugin). To configure this plugin I have to add an option to my store description.

The issue I’m facing is that I can’t figure out how to access this store description inside of a Model. I can imagine that other plugins will work the same way (options in the store description), so it might be an interesting addition to the package!

My proposed solution is to add a static field to the Model in which you could add options that are inserted (with a spread operator) into the store description. Maybe something like static piniaOptions = {}?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
CodeDreddcommented, Jul 5, 2022

@JochemVanIterson In fact where is already a way implemented:

the second argument of useRepo, takes a pinia store definition.

export function useRepo(
  modelOrRepository: any,
  storeGenerator?: (id: string) => StoreDefinition,
  connection?: string
)

but i defently will be moving pinia store defenitions to the model.

0reactions
JochemVanItersoncommented, Jul 5, 2022

But i think the persist thing will be your least problem if you want to move from vuex-orm to pinia-orm, because this is based on vuex-orm-next. So maybe some relation functions which are maybe used in your project arent yet there.

Yes, I’m also using the vuex-orm-axios and graphql plugins, but these are definitely broken on the new version (haven’t tested them though). It’s going to be a long transition I imagine!

Read more comments on GitHub >

github_iconTop Results From Across the Web

State | Pinia
In Pinia the state is defined as a function that returns the initial state. This allows Pinia to work in both Server and...
Read more >
Complex Vue 3 state management made easy with Pinia
Build a basic blog engine using Pinia, a state management tool for Vue apps, and its main features, including state, getters, and actions....
Read more >
How to pass an argument to Pinia store? - Stack Overflow
In your store, export a function that receives the session data as an argument and returns createPinia() (a Vue plugin).
Read more >
Passing arguments to useStore()? #826 - vuejs/pinia - GitHub
I occasionally need to pass arguments to my stores but haven't been able to determine if it's possible in Pinia.
Read more >
Build a To-do List App with Pinia and Vue 3
The options that I pass to the defineStore function are my ... Pinia's options follow the same mental model - I can think...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found