Skip to content

Commit

Permalink
Improve starter code
Browse files Browse the repository at this point in the history
  • Loading branch information
temeddix committed May 21, 2024
1 parent c3def8b commit 21cf17a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion flutter_ffi_plugin/example/native/hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use tokio_with_wasm::tokio; // Uncomment this line to target the web

rinf::write_interface!();

// Use `tokio::spawn` to run concurrent tasks.
// Always use non-blocking async functions
// such as `tokio::fs::File::open`.
// If you really need to use blocking code,
// use `tokio::task::spawn_blocking`.
async fn main() {
// Use `tokio::spawn` to run concurrent tasks.
tokio::spawn(sample_functions::tell_numbers());
tokio::spawn(sample_functions::stream_fractal());
tokio::spawn(sample_functions::run_debug_tests());
Expand Down
8 changes: 4 additions & 4 deletions flutter_ffi_plugin/template/messages/basic.proto
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
syntax = "proto3";
package counter_number;
package basic;

// [RINF:DART-SIGNAL]
message SmallLetter {
string letter = 1;
message SmallText {
string text = 1;
}

// [RINF:RUST-SIGNAL]
message SmallNumber {
int32 current_number = 1;
int32 number = 1;
}
6 changes: 3 additions & 3 deletions flutter_ffi_plugin/template/native/hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use tokio;

rinf::write_interface!();

// Use `tokio::spawn` to run concurrent tasks.
// Always use non-blocking async functions
// such as `tokio::fs::File::open`.
// If you really need to use blocking code,
// use `tokio::task::spawn_blocking`.
async fn main() {
// Use `tokio::spawn` to run concurrent tasks.
use messages::basic::*;
// Send signals to Dart like below.
SmallNumber { current_number: 7 }.send_signal_to_dart();
SmallNumber { number: 7 }.send_signal_to_dart();
// Get receivers that listen to Dart signals like below.
let _ = SmallLetter::get_dart_signal_receiver();
let _ = SmallText::get_dart_signal_receiver();
}

0 comments on commit 21cf17a

Please sign in to comment.