简体   繁体   English

Laravel livewire - 有什么方法可以从数据库中获取实时数据?

[英]Laravel livewire - any way to get live data from database?

I have a project for food ordering and deliverying.我有一个食品订购和交付项目。 Basically this is a concept of project:基本上这是一个项目的概念:

  • User order a food in some restaurant用户在某家餐厅点菜
  • That order of that restaurant is showing specifically to the manager of that restaurant该餐厅的订单专门显示给该餐厅的经理
  • Manager is getting SMS notification about new order经理正在收到有关新订单的短信通知
  • He needs to refresh his dashboard to see new order他需要刷新仪表板才能查看新订单

The point is in the last step Manager needs to refresh his dashboard to see new order .关键是在最后一步,经理需要刷新他的仪表板以查看新订单 I'm using livewire and Laravel 7 framework, is there any way for the manager to get new orders in realtime?我正在使用livewire和Laravel 7框架,经理有什么方法可以实时获得新订单吗?

I know for livewire polling but I don't want to use that because it can cause server problems in large quantities of using it.我知道 livewire polling ,但我不想使用它,因为大量使用它会导致服务器问题。 Is there any other way?还有其他方法吗? Something like mount() function or emit ?mount() functionemit之类的东西?

I've never used this feature but it seems you need broadcasting我从未使用过此功能,但您似乎需要广播

In many modern web applications, WebSockets are used to implement realtime, live-updating user interfaces.在许多现代 web 应用程序中,WebSockets 用于实现实时、实时更新的用户界面。 When some data is updated on the server, a message is typically sent over a WebSocket connection to be handled by the client.当服务器上的某些数据更新时,通常会通过 WebSocket 连接发送一条消息,由客户端处理。 WebSockets provide a more efficient alternative to continually polling your application's server for data changes that should be reflected in your UI. WebSockets 提供了一种更有效的替代方法,可以持续轮询应用程序的服务器以获取应该反映在 UI 中的数据更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM