Replies: 2 comments 2 replies
-
Hello,
I might miss information on this and would be very happy to have further explanations to learn more about the design decision and the ecosystem. There would also be other details of the implementation I would like to discuss based on my understanding of the specification if the opportunity arise. Thank you for your time and attention! |
Beta Was this translation helpful? Give feedback.
-
This seems to be a bug to me. I would be happy to look at any PRs removing the Clone implementation. We can tell users to use |
Beta Was this translation helpful? Give feedback.
-
Hi
gloo
maintainers!Thank you for providing this awesome library, which helps me during development of app for WASM target.
Background
In order to understand where my question comes from, I believe giving a more background could help, so here it goes:
The project I work on heavily relies on using SSE, so we're using the
EventSource
from yournet
crate.I have coded a global state using
yewdux
(we currently useyew
UI framework) which stores an instance ofEventSource
. The reason is that we have several components (sections) which uses different subscriptions (subscribing to different event types) from the same SSE route (a single instance ofEventSource
with the same URL set).I've noticed that while attempting to call
.clone()
on storedEventSource
instance in the global state, it produced an unwanted behaviour! (code reference)Please mind my beginner knowledge of the Rust, hence I created this question.
What I understood (with the help of @vpochapuis) that is happening, that once we're cloning an
EventSource
, then we're immediate losing any preciously set the connection (if any subscription was invoked). This is because of implementedDrop
trait for it. So, when it goes out of scope, it loses any existingStream
from the subscriptions. By the way, as far I could tell, it doesn't remove the existing streams, as we could understand from the implementation ofDrop
trait in the code.This caused me a trouble, because I couldn't figure out why I kept getting the
ConnectionError
, even when I confirmed that this route is working properly.I may be wrong, but this could be prevented by removing the
Clone
trait implementation forEventSource
. Hence I would like to ask and understand better why the decision was made to implement this trait. We would love to contribute on improving the API, but we need some understanding firstly. @vpochapuis has some great ideas on how to improve.Please let me know if you need more information on my use case and thank you in advance for taking a time to respond to my - hopefully not too complicated - question.
Beta Was this translation helpful? Give feedback.
All reactions