I am building a simple ecommerce site. I have decided to give LiveView a try; this is my first project using the technology. I have run into a snug that I don’t know how to solve:
I have the following LiveViews:
- One for product searching and listing - with its own URL like /products?search=laptop
- One for product detail view - with its own URL like /product/spanky-and-powerfull-laptop
- One for checkout - with its own URL like /checkout
Currently, they exist in separation.
I would like to persist the cart content of an anonymous user somewhere. I have reached for the session mechanism (cookie-based) for this task.
More generally, I guess this question is about how to pass data from (an existing) LiveView to (a newly spawned) LiveView, without storing the data in the URL.
I am thinking that organising the LiveViews in some kind of hierarchy might be one way to communicate data between LiveViews. Is that right? Are there other ways?