20 lines
479 B
Rust

use futures::sink::SinkExt;
use futures::stream::StreamExt;
use yew_agent::prelude::*;
#[reactor(Counter)]
pub async fn counter(mut scope: ReactorScope<(), u64>) {
let mut count = 0;
while let Some(_) = scope.next().await {
count += 1;
let _ = scope.send(count).await;
}
}
#[reactor(Echo)]
pub async fn echo(mut scope: ReactorScope<String, String>) {
while let Some(input) = scope.next().await {
let _ = scope.send(input).await;
}
}