Skip to content

Commit 8493cb4

Browse files
committed
a bit more documentatin for the new 'pend_after' and 'meanwhile' methods
1 parent a21dae6 commit 8493cb4

File tree

1 file changed

+11
-2
lines changed
  • async_ui_web_core/src/combinators/extras

1 file changed

+11
-2
lines changed

async_ui_web_core/src/combinators/extras/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ pub trait UiFutureExt: Future + Sized {
1111
///
1212
/// ```rust
1313
/// # async fn my_async_fn() {}
14+
/// # let _ = async {
1415
/// use async_ui_web_core::combinators::UiFutureExt;
1516
/// let fut = my_async_fn().pend_after::<std::convert::Infallible>();
1617
/// fut.await; // will never finish
18+
/// # };
1719
/// ```
1820
///
1921
/// `f.pend_after()` is equivalent to
2022
/// ```rust
2123
/// # let f = async {};
24+
/// # async { let _: i32 =
2225
/// async {
2326
/// f.await;
24-
/// std::future::pending()
27+
/// std::future::pending().await
2528
/// }
29+
/// # .await; };
2630
/// ```
2731
fn pend_after<T>(self) -> PendAfter<Self, T> {
2832
PendAfter {
@@ -34,13 +38,18 @@ pub trait UiFutureExt: Future + Sized {
3438
///
3539
/// `f.meanwhile(g)` is equivalent to
3640
/// ```rust
37-
/// # let (f, g) = (async {}, async{});
41+
/// # let (f, g) = (async {}, async {});
3842
/// # use async_ui_web_core::combinators::{UiFutureExt, race};
43+
/// # async {
3944
/// race((
4045
/// f,
4146
/// g.pend_after()
4247
/// ))
48+
/// # };
4349
/// ```
50+
///
51+
/// Use this to display UI as side-effect of some async execution.
52+
/// For example, `load_data().meanwhile(spinner()).await`.
4453
fn meanwhile<F: Future>(
4554
self,
4655
effect: F,

0 commit comments

Comments
 (0)