diff --git a/.vscode/settings.json b/.vscode/settings.json
index 2f418701b..80f51cff8 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,3 +1,3 @@
{
- "rust-analyzer.inlayHints.enable": true
+ "rust-analyzer.inlayHints.enable": false
}
\ No newline at end of file
diff --git a/README.md b/README.md
index 3d279fa42..d582339a2 100644
--- a/README.md
+++ b/README.md
@@ -23,15 +23,15 @@ Dioxus Core supports:
On top of these, we have several projects you can find in the `packages` folder.
- [x] `dioxus-cli`: Testing, development, and packaging tools for Dioxus apps
- [ ] `dioxus-router`: A hook-based router implementation for Dioxus web apps
-- [ ] `Dioxus-vscode`: Syntax highlighting, code formatting, and hints for Dioxus html! blocks
-- [ ] `Redux-rs`: Redux-style global state management
-- [ ] `Recoil-rs`: Recoil-style global state management
-- [ ] `Dioxus-iso`: Hybrid apps (SSR + Web)
-- [ ] `Dioxus-live`: Live view
-- [ ] `Dioxus-desktop`: Desktop Applications
-- [ ] `Dioxus-ios`: iOS apps
-- [ ] `Dioxus-android`: Android apps
-- [ ] `Dioxus-magic`: AR/VR Apps
+- [ ] `dioxus-vscode`: Syntax highlighting, code formatting, and hints for Dioxus html! blocks
+- [ ] `redux-rs`: Redux-style global state management
+- [ ] `recoil-rs`: Recoil-style global state management
+- [ ] `dioxus-iso`: Hybrid apps (SSR + Web)
+- [ ] `dioxus-live`: Live view
+- [ ] `dioxus-webview`: Desktop Applications
+- [ ] `dioxus-ios`: iOS apps
+- [ ] `dioxus-android`: Android apps
+- [ ] `dioxus-magic`: AR/VR Apps
## Hello World
Dioxus should look and feel just like writing functional React components. In Dioxus, there are no class components with lifecycles. All state management is done via hooks. This encourages logic reusability and lessens the burden on Dioxus to maintain a non-breaking lifecycle API.
@@ -62,7 +62,7 @@ fn Example(ctx: &Context, name: String) -> VNode {
static Example: FC = |ctx, name: String| html! {
"Hello {:?name}!"
};
```
-The final output of components must be a tree of VNodes. We provide an html macro for using JSX-style syntax to write these, though, you could use any macro, DSL, or templating engine. Work is being done on a terra template processor for existing templates.
+The final output of components must be a tree of VNodes. We provide an html macro for using JSX-style syntax to write these, though, you could use any macro, DSL, templating engine, or the constructors directly.
## Concurrency
@@ -88,7 +88,13 @@ We use the dedicated `dioxus-cli` to build and test dioxus web-apps. This can ru
Alternatively, `trunk` works but can't run examples.
- tide_ssr: Handle an HTTP request and return an html body using the html! macro. `cargo run --example tide_ssr`
-- simple_wasm: Simple WASM app that says hello. `diopack develop --example simple`
+- doc_generator: Use dioxus ssr to generate the website and docs. `cargo run --example doc_generator`
+- fc_macro: Use the functional component macro to build terse components. `cargo run --example fc_macro`
+- hello_web: Start a simple wasm app. Requires a webpacker like dioxus-cli or trunk `cargo run --example hello`
+- router: `cargo run --example router`
+- tide_ssr: `cargo run --example tide_ssr`
+- webview: Use liveview to bridge into a webview context for a simple desktop application. `cargo run --example webview`
+- twitter-clone: A full-featured Twitter clone showcasing dioxus-liveview, state management patterns, and hooks. `cargo run --example twitter`
## Documentation
We have a pretty robust
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index aef0d2331..5d131c736 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -24,13 +24,14 @@ tide = { version = "0.15.0" }
pulldown-cmark = { version = "0.8.0", default-features = false }
dioxus-webview = { path = "../packages/webview", version = "0.0.0" }
+dioxus-hooks = { path = "../packages/hooks", version = "0.0.0" }
[lib]
path = "common.rs"
[[example]]
-path = "hello.rs"
-name = "hello"
+path = "hello_web.rs"
+name = "hello_web"
[[example]]
path = "tide_ssr.rs"
diff --git a/examples/hello.rs b/examples/hello_web.rs
similarity index 100%
rename from examples/hello.rs
rename to examples/hello_web.rs
diff --git a/examples/webview.rs b/examples/webview.rs
index eaba4ddab..b9a633f12 100644
--- a/examples/webview.rs
+++ b/examples/webview.rs
@@ -1,23 +1,29 @@
+//! Example: Webview Renderer
+//!
+//! This example shows how to use the dioxus_webview crate to build a basic desktop application.
+//!
+//! Under the hood, the dioxus_webview crate bridges a native Dioxus VirtualDom with a custom prebuit application running
+//! in the webview runtime. Custom handlers are provided for the webview instance to consume patches and emit user events
+//! into the native VDom instance.
+
use dioxus::prelude::*;
fn main() {
- let app = dioxus_webview::new::<()>(|ctx| {
+ let app = dioxus_webview::new(|ctx| {
let (count, set_count) = use_state(ctx, || 0);
+
html! {
-
-
"Dioxus Desktop Demo"
-
"Count is {count}"
-
+
+
"Dioxus Desktop Demo"
+
"Count is {count}"
+
"Count is {count}"
+
"Data is {data}"
+
}
});
app.launch(());
}
-
-fn use_state(ctx: &mut Context, init: impl Fn() -> T) -> (T, impl Fn(T)) {
- let g = init();
- (g, |_| {})
-}
diff --git a/packages/dioxus/Cargo.toml b/packages/dioxus/Cargo.toml
index 4d412ae0c..5994af241 100644
--- a/packages/dioxus/Cargo.toml
+++ b/packages/dioxus/Cargo.toml
@@ -10,3 +10,4 @@ description = "Core functionality for Dioxus - a concurrent renderer-agnostic Vi
[dependencies]
dioxus-core = { path = "../core", version = "0.1.0" }
dioxus-core-macro = { path = "../core-macro", version = "0.1.0" }
+dioxus-hooks = { path = "../hooks", version = "0.0.0" }
diff --git a/packages/dioxus/src/lib.rs b/packages/dioxus/src/lib.rs
index cb1b61434..c22bc56c1 100644
--- a/packages/dioxus/src/lib.rs
+++ b/packages/dioxus/src/lib.rs
@@ -1,6 +1,7 @@
pub mod prelude {
pub use dioxus_core::prelude::*;
pub use dioxus_core_macro::fc;
+ pub use dioxus_hooks::prelude::use_state;
}
use dioxus_core::prelude::FC;
diff --git a/packages/hooks/Cargo.toml b/packages/hooks/Cargo.toml
index ad42c35f4..3696a9fa5 100644
--- a/packages/hooks/Cargo.toml
+++ b/packages/hooks/Cargo.toml
@@ -6,4 +6,5 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-[dependencies]
\ No newline at end of file
+[dependencies]
+dioxus-core = { path = "../core" }
diff --git a/packages/hooks/src/lib.rs b/packages/hooks/src/lib.rs
index 31e1bb209..980ce68e6 100644
--- a/packages/hooks/src/lib.rs
+++ b/packages/hooks/src/lib.rs
@@ -1,7 +1,7 @@
-#[cfg(test)]
-mod tests {
- #[test]
- fn it_works() {
- assert_eq!(2 + 2, 4);
+pub mod prelude {
+ use dioxus_core::prelude::Context;
+ pub fn use_state(ctx: &mut Context, init: impl Fn() -> T) -> (T, impl Fn(T)) {
+ let g = init();
+ (g, |_| {})
}
}
diff --git a/packages/redux/src/lib.rs b/packages/redux/src/lib.rs
index 31e1bb209..ba45112fa 100644
--- a/packages/redux/src/lib.rs
+++ b/packages/redux/src/lib.rs
@@ -1,7 +1,37 @@
-#[cfg(test)]
+pub struct Store {
+ user_data: T,
+}
+
+/// Select just a small bit of the
+fn use_selector() {}
+
+/*
+
+// borrow a closure so we can copy the reference
+let dispatch = use_dispatch::(ctx);
+
+
+dispatch(|| UserData::Logout)
+
+dispatch()
+
+*/
+fn use_dispatch() {}
+
mod tests {
- #[test]
- fn it_works() {
- assert_eq!(2 + 2, 4);
- }
+
+ struct UserData {}
+
+ // static SelectLoggedIn: FC = |_| {};
+
+ /*
+
+ // Merge the various stores into a single context
+ // This auto generates the appropriate selectors, reducing the need to wrap the app in excess providers
+ let all = combine_stores(vec![store1, store2]);
+
+
+
+
+ */
}
diff --git a/packages/webview/src/lib.rs b/packages/webview/src/lib.rs
index c0ad17736..0a87cedcc 100644
--- a/packages/webview/src/lib.rs
+++ b/packages/webview/src/lib.rs
@@ -37,7 +37,7 @@ impl WebviewRenderer {
todo!()
}
- pub async fn launch(self, props: T) {
+ pub fn launch(self, props: T) {
let mut ctx = Context { props: &props };
let WebviewRenderer { root } = self;
let content = root(&mut ctx);