struct
Resource
pub struct Resource {
pub data: Signal<Value>,
pub loading: Signal<bool>,
pub error: Signal<Option<String>>,
}Loading state for templates: bind it with [Resource::bind] and fill it with weft::web::load (or [Resource::set]).
let posts = Resource::new();
weft::web::load(&posts, async move { wp.posts(&query).send().await });
posts.bind(Scope::new(), "posts")
// template: if posts_loading { Skeleton } else if posts_error { Alert … } else { for p in posts { … } }Fields
Methods
bind
pub fn bind(&self, scope: Scope, name: &str) -> Scopename (the data), name_loading and name_error (text or null).