https://github.com/lunatic-solutions/submillisecond-live-view Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + By Plan + Enterprise + Teams + Compare all + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} lunatic-solutions / submillisecond-live-view Public * Notifications * Fork 0 * Star 35 Live view for the submillisecond web framework License MIT license 35 stars 0 forks Star Notifications * Code * Issues 1 * Pull requests 0 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights lunatic-solutions/submillisecond-live-view This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 0 tags Code * Clone HTTPS GitHub CLI [https://github.com/l] Use Git or checkout with SVN using the web URL. [gh repo clone lunati] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @bkolobara bkolobara Update readme and bump versions ... 0a4aa83 Nov 15, 2022 Update readme and bump versions 0a4aa83 Git stats * 79 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .cargo initial commit Sep 15, 2022 examples update README.md and remove debug log Nov 8, 2022 src Fix tests Nov 9, 2022 static Merge branch 'main' of github.com:lunatic-solutions/ submillisecond-li... Nov 8, 2022 tests Move rendered tests to builder unit tests Nov 9, 2022 web Add embedded liveview JS Nov 4, 2022 .gitignore Add embedded liveview JS Nov 4, 2022 Cargo.toml Update readme and bump versions Nov 15, 2022 LICENSE Add LICENSE Oct 19, 2022 README.md Update readme and bump versions Nov 15, 2022 liveview-debug.js Add embedded liveview JS Nov 4, 2022 liveview-release.js Add embedded liveview JS Nov 4, 2022 rustfmt.toml Add rustfmt.toml Sep 21, 2022 View code Submillisecond LiveView What is LiveView? Prerequisites Code example Running examples License README.md Submillisecond LiveView A LiveView implementation for the submillisecond web framework built with lunatic. What is LiveView? LiveView provides rich, real-time user experiences with server-rendered HTML. The LiveView programming model is declarative: instead of saying "once event X happens, change Y on the page", events in LiveView are regular messages which may cause changes to its state. Once the state changes, LiveView will re-render the relevant parts of its HTML template and push it to the browser, which updates itself in the most efficient manner. This means developers write LiveView templates as any other server-rendered HTML and LiveView does the hard work of tracking changes and sending the relevant diffs to the browser. It was made popular by the Phoenix webframework for Elixir. Prerequisites Lunatic runtime is required, along with the wasm32-wasi target. cargo install lunatic-runtime rustup target add wasm32-wasi It is also recommended to add a .cargo/config.toml file with the build target and runner configured. # .cargo/config.toml [build] target = "wasm32-wasi" [target.wasm32-wasi] runner = "lunatic" Code example use serde::{Deserialize, Serialize}; use submillisecond::{router, static_router, Application}; use submillisecond_live_view::prelude::*; fn main() -> std::io::Result<()> { Application::new(router! { "/" => Counter::handler() "/static" => static_router!("./static") }) .serve("127.0.0.1:3000") } #[derive(Clone, Serialize, Deserialize)] struct Counter { count: i32, } impl LiveView for Counter { type Events = (Increment, Decrement); fn mount(_uri: Uri, _socket: Option<&mut Socket>) -> Self { Counter { count: 0 } } fn render(&self) -> Rendered { html! { button @click=(Increment) { "Increment" } button @click=(Decrement) { "Decrement" } p { "Count is " (self.count) } } } } #[derive(Deserialize)] struct Increment {} impl LiveViewEvent for Counter { fn handle(state: &mut Self, _event: Increment) { state.count += 1; } } #[derive(Deserialize)] struct Decrement {} impl LiveViewEvent for Counter { fn handle(state: &mut Self, _event: Decrement) { state.count -= 1; } } Running examples Clone the repository git clone git@github.com:lunatic-solutions/submillisecond-live-view.git cd submillisecond-live-view Run an example cargo run --example clock License Licensed under either of * Apache License, Version 2.0, (http://www.apache.org/licenses/ LICENSE-2.0) * MIT license (http://opensource.org/licenses/MIT) at your option. About Live view for the submillisecond web framework Resources Readme License MIT license Stars 35 stars Watchers 2 watching Forks 0 forks Releases No releases published Packages 0 No packages published Used by 1 * @bkolobara @bkolobara / live-view-chat Contributors 2 * @tqwewe tqwewe Ari Seyhun * @bkolobara bkolobara Bernard Kolobara Languages * JavaScript 63.3% * Rust 33.3% * CSS 3.4% Footer (c) 2022 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.