.worker(
"/",
ProgressiveWorker::new("catalog-filters", "/assets/workers/catalog-filters.wasm")
.entry("pokemon_card_store::workers::catalog_filters_boot")
.root_node_id("catalog-grid")
.description("Client-side filtering and sort controls over server-rendered cards."),
)
pub fn catalog_filters_boot(input: &str) -> String {
let message: serde_json::Value = serde_json::from_str(input)
.unwrap_or_else(|_| serde_json::json!({ "type": "boot" }));
serde_json::json!({
"messages": [{
"type": "dom_batch",
"sequence": message.get("sequence").and_then(|v| v.as_u64()).unwrap_or(1),
"transaction_id": "catalog-filters",
"ops": [
{
"op": "set_text_by_semantics",
"semantics": "worker-status:catalog-filters",
"text": "Worker bridge ready"
}
]
}],
"bindings": []
}).to_string()
}
.island(
"/",
WasmIsland::new(
"cart-drawer",
"/assets/islands/cart-drawer.wasm",
"cart-drawer",
)
.entry("pokemon_card_store::islands::cart_drawer_boot")
.description("Focused Fission island for cart state, checkout totals, and item edits."),
)
SemanticsRegion::new(
Container::new(Text::new("Island booting").into())
.padding_all(18.0)
.into(),
)
.id(fission::WidgetId::explicit("cart-drawer"))
.identifier("cart-drawer")
.into()
#[derive(Debug, Default, Clone)]
pub struct BrowserCartState {
count: u32,
}
impl GlobalState for BrowserCartState {}
#[derive(Clone)]
pub struct CartDrawerIsland;
impl From<CartDrawerIsland> for Widget {
fn from(component: CartDrawerIsland) -> Self {
let (ctx, view) = fission::build::current::<BrowserCartState>();
let add = ctx.bind(IslandAddToCart, reduce_with!(on_island_add_to_cart));
SemanticsRegion::new(
Container::new(Text::new(format!("{} items", view.state().count)).into())
.padding_all(12.0)
.into(),
)
.identifier("island-action:add-card")
.role(fission::Role::Button)
.default_action(add)
.into()
}
}
#[fission_reducer(IslandAddToCart)]
pub fn on_island_add_to_cart(state: &mut BrowserCartState) {
state.count += 1;
}
pub fn cart_drawer_boot(input: &str) -> String {
run_browser_island("cart-drawer", input, || {
BrowserIslandApp::new(
"cart-drawer",
"cart-drawer",
BrowserCartState::default(),
CartDrawerIsland,
)
})
}
fission server artifacts --project-dir examples/pokemon-card-store
Need | Use |
|---|---|
Collapse a menu, toggle a filter, sort visible rows | Worker |
Cart drawer, live editor, rich control panel | Island |
Whole app runs in browser and owns the canvas/runtime | Web target |
Page has no runtime behavior beyond links | Static site or server-rendered HTML |
Symptom | What to check first |
|---|---|
The app compiles but nothing changes | Confirm the component is actually used by the route or shell target you are running. |
An action fires but state does not update | Confirm the reducer is registered with the same action value that the UI dispatches. |
A platform feature reports unsupported | Confirm the target has the capability in fission.toml and the shell registered the provider. |
The page works on one target but not another | Run fission doctor, then inspect target-specific configuration and feature flags. |
Tests are hard to write | Split the product rule into a reducer test first, then add a UI or shell smoke test for the integration. |