-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server Sent Event support #1346
Comments
I was in need of server send events as well. Therefore i created this little library: https://github.com/liquidblock/yew-sse match self.sse.open(
&url,
self.link.callback(move |(id, message): (String, String)| {
Message::SendEventMessage(id, message)
}),
self.link.callback(move |value: EventSourceUpdate| {
match value {
EventSourceUpdate::Open => Message::SendEventOpen,
EventSourceUpdate::Error => Message::SendEventError,
}
}),
) {
Ok(task) => {
self.task = Some(task);
}
Err(e) => {
// error handling
}
}
The library works with |
I'm going to start taking a look at this |
@LiquidBlock , do you plan to merge your crate as a service? |
I've returned after a hard fall/winter to look at what @LiquidBlock has and to try to merge it into the code base. As this is my first foray into open source development, if anyone could offer up some time to walk me through a few things, I'd be REALLY grateful. I've gone through and read the yew/CONTRIBUTING.md file along with the external links listed in said file. For now, I'll get myself acquainted with his code base, clean up anything that may need cleaning up, and start with adding documentation. |
I prefer to be referred to by they/them pronouns.
The reason as to why I did not create a PR of my crate as a service in yew is because of my missing documentation, tests and examples. I would be interested in helping out moving the code into yew. Also looking back at my code, there are some suggestions for further implementing SSE as a yew specific service:
|
@LiquidBlock Good idea is to use warp as a server - it does have SSE support https://github.com/seanmonstar/warp/blob/master/examples/sse_chat.rs, https://github.com/seanmonstar/warp/blob/master/examples/sse.rs. |
@LiquidBlock I’m sorry - I shouldn’t have assumed. I’ll remember to use inclusive language in the future. |
@LiquidBlock id love some help if you have the time to offer it. I’m with my partner this weekend, so I’ll be very sparse with communications, but on Monday, I’ll be back to it and maybe we can work together 😀 |
@thedanvail do you have a Discord account? There is a yew Discord server (the link is in yews readme). |
@LiquidBlock I do - I'll hop into that one. Unfortunately, I'm in CST time, so that's coincided with my work day, but I'll still do my best to knock out what I can! If I have problems/questions, would you mind if I messaged you? |
In case it is useful, I have this little library which I have extracted from some of my other code: https://github.com/strawlab/yew-event-source . You are welcome to incorporate as much or as little as you like directly into yew. |
Hello everyone, Regrettably, I think this is just beyond my skill level right now. I'd rather say this outright than just disappear into the ether. It'd be to the point where I was just riding off the coattails of whomever I would ask for help. So, I have to drop this from my plate; if anyone else can pick it up, please feel free! Thanks to @LiquidBlock for their help this far, and hopefully, when my JS/Rust skills are stronger, I can come and contribute in another way :) |
@thedanvail thanks for the update. Please come back anytime! Since there are two crates that implement SSE mentioned above (liquidblock's https://github.com/liquidblock/yew-sse and my https://github.com/strawlab/yew-event-source), it seems the most substantial hurdle for inclusion directly into yew is writing an example. (And possibly a test case, although the websocket service does not have that. Perhaps our standards are higher now and we should include tests for SSE and, while we are at it, for websockets.) Since this is tagged with "good first issue", I will point out that the dashboard example uses the websocket service and hopefully could serve as a basis for new example for event source. I would say that for a "first issue", I would not require the initial implementation to include the test infrastructure to start a server. |
|
Describe the feature you'd like
Adding a
yew::service
for Server Sent Events, I imagine this one wouldn't be too difficult to add as it would behave similar to a one-way Websocket, and web_sys has support for the EventSource object.Describe alternatives you've considered (Optional)
While this can handled with Websockets as an alternative, the use cases are somewhat different, owing to communication being uni-directional.
Questionnaire
The text was updated successfully, but these errors were encountered: