mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
fix tests
This commit is contained in:
parent
db654cbfda
commit
43c0e384c4
2 changed files with 11 additions and 6 deletions
|
@ -672,9 +672,13 @@ pub mod write {
|
|||
///
|
||||
/// ## Examples
|
||||
/// ```rust
|
||||
/// # use leptos_reactive::*;
|
||||
/// # let runtime = create_runtime();
|
||||
/// let (count, set_count) = create_signal(2);
|
||||
/// # use reactive_graph::prelude::*;
|
||||
/// # use reactive_graph::wrappers::write::SignalSetter;
|
||||
/// # use reactive_graph::signal::signal;
|
||||
/// # tokio_test::block_on(async move {
|
||||
/// # any_spawner::Executor::init_tokio();
|
||||
/// # let _guard = reactive_graph::diagnostics::SpecialNonReactiveZone::enter();
|
||||
/// let (count, set_count) = signal(2);
|
||||
/// let set_double_input = SignalSetter::map(move |n| set_count.set(n * 2));
|
||||
///
|
||||
/// // this function takes any kind of signal setter
|
||||
|
@ -688,7 +692,7 @@ pub mod write {
|
|||
/// assert_eq!(count.get(), 4);
|
||||
/// set_to_4(&set_double_input);
|
||||
/// assert_eq!(count.get(), 8);
|
||||
/// # runtime.dispose();
|
||||
/// # });
|
||||
/// ```
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct SignalSetter<T>
|
||||
|
|
|
@ -4,6 +4,7 @@ use reactive_graph::{
|
|||
signal::RwSignal,
|
||||
traits::{Get, Read, Set, With, WithUntracked},
|
||||
};
|
||||
use std::future::pending;
|
||||
|
||||
#[tokio::test]
|
||||
async fn arc_async_derived_calculates_eagerly() {
|
||||
|
@ -83,7 +84,7 @@ async fn async_derived_tracks_signal_change() {
|
|||
async fn read_signal_traits_on_arc() {
|
||||
_ = Executor::init_tokio();
|
||||
|
||||
let value = ArcAsyncDerived::new(move || async {});
|
||||
let value = ArcAsyncDerived::new(pending::<()>);
|
||||
assert_eq!(value.read(), AsyncState::Loading);
|
||||
assert_eq!(value.with_untracked(|n| *n), AsyncState::Loading);
|
||||
assert_eq!(value.with(|n| *n), AsyncState::Loading);
|
||||
|
@ -94,7 +95,7 @@ async fn read_signal_traits_on_arc() {
|
|||
async fn read_signal_traits_on_arena() {
|
||||
_ = Executor::init_tokio();
|
||||
|
||||
let value = AsyncDerived::new(move || async {});
|
||||
let value = AsyncDerived::new(pending::<()>);
|
||||
println!("{:?}", value.read());
|
||||
assert_eq!(value.read(), AsyncState::Loading);
|
||||
assert_eq!(value.with_untracked(|n| *n), AsyncState::Loading);
|
||||
|
|
Loading…
Reference in a new issue