2024-03-04
This is Luca Cappelletti's DBGI daily open-notebook.
Today is 2024.03.04
Todo today
- Setup WebSockets for the emi-monorepo to allow the frontend to receive updates from the backend
Doing
- Since adding the code directly would be a lot of work to debug, I started by creating a prototype in the actix_yew_websockets repo. Once it works, I will integrate it into the emi-monorepo.
Done
- Managed to get several points of the integration of the WebSockets between the frontend and the backend working. I still do not understand severela key points of the concrete integration between frontend and backend, but I am making progress.
- Contacted authors of ezsockets and yew-websocket who already worked on similar problems to ask for help. It is unclear whether their repos are still maintained, but I will try to get in touch with them.
Notes
- One of the alternatives to Yew as a frontend framework called Leptos that seems to support WebSockets out of the box. Yew used to support Websockets, but for reasons they dropped support for it, I have no idea yet why. Swtching the repo at this point to Leptos would be a lot of work, but it could be a good alternative for the future. I still hope to get Yew to work for now.
- Found this tutorial on using WebWorkers which could be useful for part of the work with WebSockets.
- While in this tutorial they use a Yew Agent to handle the multi-subscribers issues to a websocket it seems that in the latest yew-agents they renames Agents to Workers and now handle the multi-subscriber issue out of the box with methods such as use_reactor_subscription. They renamed agents to workers because they use WebWorkers under the hood, and by calling them workers they make it clear that WebWorkers are used under the hood.
- I have found this tutorial that makes use of the use_reactor_subscription method, which may be an important Rosetta stone to understand how to use WebWorkers & WebSockets with Yew.
Todo tomorrow
- Remove reqwasm as apparently they stopped developmemt and merged it into gloo-net.
- Continue trying to get WebSockets to work with Yew.
- Understand how to convert standard WebSocket messages, such as Text and Bytes, or more as listed from the actix web actors, into a standardized and more general pourpose enumeration that may be used with Yew Agents in our application. I hope to find some documentation that is less tautological than the one I found so far.