-
I was doing experiments with this tool and wanted to thank before the suggestion I would make so thanks for the good work! The experiment was about feeding data from rust to flutter in a continuous manner. Imagine rust doing something like;
but instead of adding data to In the scenario above, it takes approximately 8 seconds in my test for flutter to update the widget since it is waiting for rust to collect 1_000_000 number all together in the Is it possible to achieve something like that currently? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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_signal_to_dart(None);
tokio::time::sleep(std::time::Duration::from_secs(0.001)).await;
}
} Your code would look something like this. This tutorial section, 'From Rust to Dart' will explain the process in more detail. If you have any other questions, please let me know :) P.S. Updating a widget with |
Beta Was this translation helpful? Give feedback.
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...