# suspense

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-view/async_data/function-suspense/

**function** · [`ferroui-view`](/docs/0.5.0/api/ferroui-view/) · v0.5.0

```rust
fn suspense<T: Clone + 'static>(state: crate::reactive::Signal<AsyncState<T>>, pending: impl Fn() -> crate::element::Element + 'static, ready: impl Fn(T) -> crate::element::Element + 'static, failed: impl Fn(String) -> crate::element::Element + 'static) -> crate::element::Element
```

An element that follows `state`: the element of `pending()` while it is
pending, of `ready(value)` once it is ready, and of `failed(message)` once
it failed. It is a component that runs again when the state changes; the
reconciler patches what the closures return, so the elements of two
states with the same controls keep them.

```ignore
let people = use_future(query.get(), |query| load_people(query.clone()));
suspense(
    people,
    || rsx! { TextBlock { text: "Loading..." } },
    |people| rsx! { ListBox { for p in &people { ListBoxItem { key: p.id, content: p.name.clone() } } } },
    |error| rsx! { TextBlock { text: error } },
)
```

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/async_data.rs#L204)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
