Private workers are not destroyed properly because Destroy messages are not sent when a PrivateBridge is dropped.
https://github.com/yewstack/yew/blob/1ede16795a8f08975708e1808c0d528f31d5c946/src/agent.rs#L481
Copy public worker solution. Make it DRY if possible
I've started to look into this issue and wanted your input on how to solve this. Would we have to replicate the same model used for public agents where they're stored inside an agent pool as we have on https://github.com/yewstack/yew/blob/5491bf99ccb1970da6a6dc3fbc6647604e7a9b62/yew/src/agent.rs#L573 ?
Nope, no need because private agents are only connected to from a single client and so there's a one to one mapping from client to agent and only a single bridge involved. Public agents can be connected to from multiple clients at the same time and so REMOTE_AGENTS_POOL is a mechanism for clients to discover an already existing agent when creating additional bridges.
The key part for this issue is here:
https://github.com/yewstack/yew/blob/a91e7f651253382ac9abafb5ca2e0e0df669cd2c/yew/src/agent.rs#L741-L746
Thanks for the tip, @jstarry. In that case I'd need to add an ID to the private bridge, given that it currently has no ID and the Disconnected message has an ID attached to it.
To make things simple, given the 1:1 relation, would it be ok to just send an arbitrary ID like 0 or would I have to use something like a static counter to guarantee that the ID is unique always?
0 is fine! I guess that's probably why Connected and Disconnected were never implemented 馃槤
Speaking of which, while you're at it can you fix: https://github.com/yewstack/yew/issues/948? It's very related
@joaquindk oh we already have this actually, SINGLETON_ID
Perfect, I鈥檒l also take care of #948 in that case 鈽猴笍