Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Cool. Can you use svelte stores across multiple liveview navigations?


That's something I need to look into. - Should be possible by saving the store in the localstorage and fetching it again on a different page. - Or saving the store to the window[1], as long as the page transitions happen through a live redirect[2] it should still be there.

I'm building a collection of examples[3] and if I can get it working I'll add it.

[1] https://wout.space/notes/how-to-share-store-between-multiple...

[2] https://hexdocs.pm/phoenix_live_view/live-navigation.html

[3] https://github.com/woutdp/live_svelte/tree/master/examples


Yea, for sure it should be possible to do it with local storage but the real cool thing would be to be able to keep state in js between live redirects. Like you said it should be possible if using live redirect. Would love that. Good luck! Hope to be able to use your library in the future.


Hey, I got a simple example of using stores where you live redirect between 2 liveviews but the store information is kept. Was able to do it with saving the store to the window:

https://github.com/woutdp/live_svelte/tree/master/examples/s...

What could be cool if I can somehow map the reactive liveview state directly to a store... not sure how to do this yet but hope I can figure it out




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: