Open nimo23 opened 8 months ago
here is stream_fetch
command for tauri
rust code: stream.rs
mod stream;
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![stream::stream_fetch])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
js code: stream.ts
import { fetch as tauriStreamFetch } from "./stream"
import { fetchEventSource } from '@microsoft/fetch-event-source';
await fetchEventSource('/api/sse', {
fetch: tauriStreamFetch,
onmessage(ev) {
console.log(ev.data);
}
});
Describe the problem
Currently we need to use
@tauriApps/plugin-websocket
for unidirectional streaming (from server to client). However, there is another web standard specifically for such unidirectional streaming: Server Sent Events (SSE).Describe the solution you'd like
Would be nice to also have
@tauriApps/plugin-sse
to support "server sent events".Especially for mobile applications, SSE is a much more energy-saving alternative. Btw, in contrast to the use of the "web's native implementation", Tauri can even improve SSE communication by
Alternatives considered
No response
Additional context
No response