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

feat✨: allow to change and persist cookie before nuxt init #229

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MZ-Dlovely
Copy link
Contributor

Description

when opening a page on bowser, nuxt will be initialized and generate a html as response. if you are doing some thing like useStore and change store with nuxt's plugin, it will not persist state because there is no nuxt instance.

so, I make a new nitro plugin to make sure the initialize connection can obtain data of cookies from client side, and set cookies after pinia store is changed.

but the problem that our plugin is not able to get nuxt instance is still unresolved, so I provided a method to tell the plugin what to pass.

Linked Issues

#221

Additional context

maybe we need to test how it work after many revision

@prazdevs
Copy link
Owner

will have a look when i get some time 👍

@prazdevs
Copy link
Owner

sorry been really overloaded with work atm, havent found time yet to look into it 😓

@prazdevs
Copy link
Owner

prazdevs commented Sep 4, 2023

I checked a bit and played with it. I like where this is going and it makes working with stores in middleware possible, however, I'm not sure this is the final API we want, especially the persistCookie . Maybe we can find a way to reuse the store config ?

@MZ-Dlovely
Copy link
Contributor Author

I checked a bit and played with it. I like where this is going and it makes working with stores in middleware possible, however, I'm not sure this is the final API we want, especially the persistCookie . Maybe we can find a way to reuse the store config ?

I try to do the same thing inset the plugin like persistCookie doing, but it's not possible to obtain event because the env of plugin is lay in outside of nuxt(I cannot understand).so I have to extract it for users to use. maybe someone can come up with a better plan? :P

@prazdevs
Copy link
Owner

prazdevs commented Sep 6, 2023

Ok so maybe we could just copy/paste the pick method to the nuxt plugin to avoid touching the base plugin at all while we work on the Nuxt thing.
Later if we ever export it, we may want to strip it from types as it's an internal thing as well 🤔

Then we merge and move forward to see how we can improve it. But at least people can try playing around with it. Maybe tag is as experimental or sth

@MZ-Dlovely
Copy link
Contributor Author

MZ-Dlovely commented Sep 7, 2023

cannot agree more

maybe, we can use the get and set of lodash-es instead of pick and others? then each performs its own functions.

@prazdevs
Copy link
Owner

prazdevs commented Sep 7, 2023

Ig it's fine using lodash-es in the Nuxt plugin, we'll see later what we can do. This issue has to be adressed so let's try things! I let you update the PR with whatever is needed from lodash to avoid changing the base plugin. So modifications only happen in the Nuxt package. :)

@MZ-Dlovely
Copy link
Contributor Author

I'm sorry I have no enough time to do it last week. maybe there's time in a few days.

@prazdevs
Copy link
Owner

nw take your time ^_^ lodash are working on a v5 with native typescript, usm exports so could be a good start to see what we can do with it when they're done too.
if it's really worth it we can always even put it in the main plugin. 👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants