use fission::prelude::*;
// Inside the catalog parent's Compose view setup block:
let request = state.product_request();
let loaded = cx.bind(ProductsLoaded, reduce!(on_products_loaded));
let failed = cx.bind(ProductsFailed, reduce!(on_products_failed));
let products = FutureBuilder::new(
ResourceKey::new("catalog.products"),
PRODUCTS_JOB,
request.clone(),
state.products.clone(),
|_ctx, _view, snapshot| {
ProductList {
snapshot: snapshot.clone(),
}
.into()
},
)
.deps(request)
.on_ok(loaded)
.on_err(failed);
// Use products as an ordinary Rust expression in the parent Compose tree.
Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
key | ResourceKey | Stable identity for this job resource. | Keep it stable for the logical resource, not for a single frame. |
job | JobRef<J> | The registered job to run. | The shell must register a handler for the job. |
request | J::Request | Request payload passed to the job. | Cloneable request value. |
snapshot | AsyncSnapshot<J::Ok, J::Err> | Current app-owned loading/data/error state. | Reducers update it after job callbacks. |
on_ok | Option<ActionEnvelope> | Action dispatched when the job succeeds. | Use this to bind the success reducer. |
on_err | Option<ActionEnvelope> | Action dispatched when the job fails. | Use this to bind the error reducer. |
deps | Option<Vec<u8>> | Serialized dependency identity. | Changing deps restarts or preserves according to policy. |
policy | ResourcePolicy | How resource changes are handled. | Defaults to RestartOnChange. |
builder | AsyncWidgetBuilder<S, J::Ok, J::Err> | Pure closure that turns the current snapshot into UI. | Keep the closure small; delegate real UI to a named component that receives the snapshot. |