Skip to content

Streaming data from rust to flutter instead of responding with whole data #278

Answered by temeddix
yakupars asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @yakupars , thank you for starting this discussion!

Yes, what you've described is totally achievable with Rinf. You can simply use Rust signals to do that.

Assuming that you're using Rinf 6 beta...

// messages/my_resource.proto

// [RINF:RUST-SIGNAL]
message MyMessage {
    string each_text = 1;
}
// lib/main.dart

MyMessage.rustSignalStream.listen((rustSignal) {
    final eachText = rustSignal.message.eachText;
    // Your custom Dart logic here.
    // Or, simply use `StreamBuilder` instead.
});
// native/hub/src/sample_functions.rs

pub async fn stream_my_number() {
    use messages::my_resource::*;

    for n in 1..1_000_000 {
        MyMessage { each_text: n.to_string() }.send_sig…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yakupars
Comment options

Answer selected by yakupars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants