Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
280 views
in Technique[技术] by (71.8m points)

Laravel livewire sync between multiple devices (instances)

I have a livewire component called Cart.

If the user open this component in multiple devices at the same time (i.e. mobile and desktop, or open it in multiple browser tabs), and add an item to the cart in the mobile browser, is there a way to refresh the component in desktop browser?

I know these components are independent of each other, so I'm thinking of a solution where I have to store, for example, the component ID (or something like that) and create the another one based on it.

Is there a well-developed solution to this?

question from:https://stackoverflow.com/questions/65941943/laravel-livewire-sync-between-multiple-devices-instances

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'm not aware of any existing solution like this but you could save the cart in DB and then retrieve it for all your platforms. To make it so it's always synced on both platforms you could build your mobile application on APIs or otherwise use something like the Broadcasting within Laravel or a package like Laravel WebSockets.

Livewire is more for building dynamic interfaces removing the complexity of making AJAX requests in the background and doesn't support multiple platforms the way you are wanting.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...