Refactor: untangle framework library from todo example
The codebase is now split into two clear layers: Framework library (src/): - lib.rs — public API surface, re-exports all framework types - signal.rs — SignalOpts, Signal, SignalStore, mangle/global/client_only helpers - query.rs — Query trait, CacheKey, query_one!/query_all! macros (macro paths updated from $crate::framework::* to $crate::*) - context.rs — RenderContext, ComponentTree, ComponentNode - connection.rs — ConnectionManager, SubscriptionRegistry, ConnectionState - sse.rs — format_patch_elements, format_patch_signals - server.rs — AppState, SharedState, sse_handler (pure framework plumbing) Todo example (examples/todo/): - main.rs — SQLite setup, seeding, server bootstrap - app.rs — router, document_shell, resolve_and_render, render_page, action_then_render, and all HTTP handlers - queries.rs — Todo model, ListTodos/GetTodo queries, mutation helpers - todo_list.rs — TodoList page component - about.rs — About page component Run the example independently with: cargo run --example todo https://claude.ai/code/session_01JThiQbp3Bn9J1VhBpRuz4u
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
use livevue_rs::RenderContext;
|
||||
use maud::{html, Markup};
|
||||
|
||||
/// Second page component: a simple "About" page.
|
||||
///
|
||||
/// This exists specifically to exercise:
|
||||
/// - The `tree` signal page routing (resolve_root match arm)
|
||||
/// - SPA-like navigation via tree signal mutation
|
||||
/// - Round-trip: TodoList → About → TodoList without full page reload
|
||||
///
|
||||
/// In a real app this might show user info, settings, etc.
|
||||
pub async fn about(_cx: &mut RenderContext) -> anyhow::Result<Markup> {
|
||||
Ok(html! {
|
||||
div.about-page {
|
||||
h1 { "About LiveVue.rs" }
|
||||
|
||||
nav {
|
||||
button.nav-link
|
||||
data-on-click="$tree = {page: 'TodoList'}; @post('/render')" {
|
||||
"Todos"
|
||||
}
|
||||
" | "
|
||||
span.nav-current { "About" }
|
||||
}
|
||||
|
||||
div.about-content {
|
||||
p {
|
||||
"LiveVue.rs is a reactive server-side rendering framework for Rust. "
|
||||
"The server renders full-page HTML on every state change. "
|
||||
"DataStar morphs it into the DOM."
|
||||
}
|
||||
p {
|
||||
"The architectural bet: "
|
||||
strong { "full rerender is cheap" }
|
||||
", so skip diffing, skip partial updates, skip client-side state management."
|
||||
}
|
||||
h2 { "v0 Status" }
|
||||
ul {
|
||||
li { "Single process, single node" }
|
||||
li { "SQLite for storage" }
|
||||
li { "Subscription keys collected (Phase 2 seam)" }
|
||||
li { "No cache, no auth, no WAL consumer" }
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user