use fission::prelude::*;
let products = FutureBuilder::new(
ResourceKey::new("catalog.products"),
PRODUCTS_JOB,
view.state.product_request(),
view.state.products.clone(),
|ctx, view, snapshot| {
ProductList {
snapshot: snapshot.clone(),
}
.build(ctx, view)
},
)
.deps(view.state.product_request())
.on_ok(with_reducer!(ctx, ProductsLoaded, on_products_loaded))
.on_err(with_reducer!(ctx, ProductsFailed, on_products_failed))
.build(ctx, view);
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 | Closure that renders the current snapshot. | Keep it pure; do not perform side effects inside it. |