fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
3.61k stars 254 forks source link

After #1867, StreamSink never returns #1873

Closed Jhonfunk closed 1 month ago

Jhonfunk commented 1 month ago

After #1867, StreamSink does not return until the rust function has finished. So how about those streams that need to last a long time?

fzyzcjy commented 1 month ago

Hi, what about this:

pub fn func(sink: StreamSink<String>) {
    (FLUTTER_RUST_BRIDGE_HANDLER.thread_pool()).execute(transfer!(|| {
        ... your long executing code here ...
    }));
}

Alternatively, you can spawn a thread by whatever other approaches you like.

NightBlaze commented 1 month ago

I don't have issues with StreamSink but agree with @fzyzcjy solution. I think that the right approach is that an application should always be asynchronous/multithreaded and should not block waiting for a response.

github-actions[bot] commented 3 weeks ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.