Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
366 commits
Select commit Hold shift + click to select a range
3f6f855
remove is dirty
ealmloff Jun 12, 2026
2d40518
clean up comments in ssr
ealmloff Jun 15, 2026
8b761df
remove HYDRATION_INJECT_MARKER
ealmloff Jun 15, 2026
581ef3d
dyn writer
ealmloff Jun 15, 2026
a61951b
pull out const vec
ealmloff Jun 16, 2026
06970e8
rework template structure
ealmloff Jun 16, 2026
e4d1d7b
use the builder api in html
ealmloff Jun 16, 2026
dd4e8ed
remove list diffing logic from anchor
ealmloff Jun 16, 2026
6ae6e1a
clean up core api
ealmloff Jun 16, 2026
589e8bc
promote the rsx expansion to the only path
ealmloff Jun 16, 2026
eb88a9e
fix pathological anchor case and clean up custom element example
ealmloff Jun 16, 2026
4fff5cc
clean up html builder example
ealmloff Jun 16, 2026
3755614
optimize core to reduce benchmark regressions
ealmloff Jun 16, 2026
44a9a9b
make const vec mutable
ealmloff Jun 16, 2026
3a39221
clean up template traits
ealmloff Jun 16, 2026
069ee7e
pull out const vec
ealmloff Jun 16, 2026
38a7f18
optimize core to reduce benchmark regressions (const-vec portion)
ealmloff Jun 16, 2026
f308298
make const vec mutable
ealmloff Jun 16, 2026
3eb46dc
rename const-vec to dioxus-const-vec
devin-ai-integration[bot] Jun 16, 2026
fc455b5
refactor(core): extract RenderDriver trait from PR #5554
devin-ai-integration[bot] Jun 16, 2026
720e07b
move mounted data out of vnode
ealmloff Jun 16, 2026
edc054f
fix(core): fix suspense resolution with RenderDriver trait
devin-ai-integration[bot] Jun 17, 2026
f5e6893
refactor: replace dyn RenderDriver + DynWriter with enum dispatch
devin-ai-integration[bot] Jun 17, 2026
a5b7b0c
refactor: use trait object RenderDriver with direct dyn WriteMutation…
devin-ai-integration[bot] Jun 17, 2026
6d66bf6
fuzzer passing
ealmloff Jun 17, 2026
5539af8
update manganis callers for &mut ConstVec API
devin-ai-integration[bot] Jun 17, 2026
0fa533a
remove writes_are_noops
ealmloff Jun 17, 2026
084dd45
remove fn suspense_context
ealmloff Jun 17, 2026
3dd2e13
use dyn everywhere
ealmloff Jun 17, 2026
89c9e34
remove refcell around suspense_location
ealmloff Jun 17, 2026
23d888c
leave public virtual dom api unchanged
ealmloff Jun 17, 2026
31f8d5b
restore signature for resolve_suspense
ealmloff Jun 17, 2026
64c12cf
fix clippy
ealmloff Jun 17, 2026
5af2e21
revert memorize behavior for suspense to match main
ealmloff Jun 17, 2026
38bb5a4
match generic on existing resolve suspense
ealmloff Jun 17, 2026
8bb490f
decouple prop diffing and lifecycle driver
ealmloff Jun 17, 2026
0edbf93
clean up diff
ealmloff Jun 17, 2026
ca99bf9
undo rename
ealmloff Jun 17, 2026
e2eedb6
clean up suspense component diff
ealmloff Jun 17, 2026
d602010
fix native integration
ealmloff Jun 17, 2026
f8b933c
remove virtual placeholder nodes in ts
ealmloff Jun 17, 2026
b2cf35a
Merge commit 'refs/tmp/pr5633' into fix-textarea-hydration
ealmloff Jun 17, 2026
3bfa127
Merge commit 'refs/tmp/pr5634' into fix-textarea-hydration
ealmloff Jun 17, 2026
43af0a1
Refactor core render drivers
ealmloff Jun 17, 2026
322182d
pull out stack
ealmloff Jun 17, 2026
4ffb269
remove string template cache - no perf impact
ealmloff Jun 17, 2026
ff3fcea
clean up templates api
ealmloff Jun 17, 2026
8a26417
move hydration back into rust
ealmloff Jun 17, 2026
ea05f96
rename to walk
ealmloff Jun 17, 2026
82f88a8
rename view items and make more of core private
ealmloff Jun 17, 2026
53ae6f8
split up template
ealmloff Jun 17, 2026
9c790ba
remove RuntimeTemplateBuilder
ealmloff Jun 17, 2026
69fa09b
calibrate default const allocations
ealmloff Jun 17, 2026
0f3a515
pull out template lib and handle large rsx blocks
ealmloff Jun 17, 2026
327ebfd
rename TemplateStorageEstimate
ealmloff Jun 17, 2026
07000f0
fix keyed diffing regression
ealmloff Jun 17, 2026
a900a6d
remove TemplateSlotTarget
ealmloff Jun 17, 2026
183e6e8
make drop_scope mimic main
ealmloff Jun 17, 2026
dcc65fe
move all of the const work to the end of the builder to reduce alloca…
ealmloff Jun 17, 2026
87860bc
move all of the const work to the end of the builder to reduce alloca…
ealmloff Jun 17, 2026
9788b1e
clean up some tests
ealmloff Jun 17, 2026
1ef9b1a
fix window component
ealmloff Jun 17, 2026
a3fd4d8
fix tests
ealmloff Jun 17, 2026
43b0c02
fix docsite
ealmloff Jun 18, 2026
65fe14a
fix hydration
ealmloff Jun 18, 2026
cfe9938
improve const component builder api
ealmloff Jun 18, 2026
3c2d254
remove raw api
ealmloff Jun 18, 2026
5d9575a
clean up documentation around templates
ealmloff Jun 18, 2026
4b1c830
handle renderer removal
ealmloff Jun 18, 2026
55e1f53
hide some marker types
ealmloff Jun 18, 2026
83592b8
fix html conflict
ealmloff Jun 18, 2026
16fa13c
revert .gitignore
ealmloff Jun 18, 2026
e245cf0
clean up web lib diff
ealmloff Jun 18, 2026
dff5930
revert useless fullstack document change
ealmloff Jun 18, 2026
b9917c4
clean up cache diff
ealmloff Jun 18, 2026
807c6fc
clean up some wrappers
ealmloff Jun 18, 2026
82c206b
Merge remote-tracking branch 'ealmloff/fix-textarea-hydration' into f…
ealmloff Jun 18, 2026
b32ac11
fix scope drop
ealmloff Jun 18, 2026
c2d381d
cut down on rsx public api
ealmloff Jun 18, 2026
7f0599f
fix mount event element id and dynamic value shape comparison
ealmloff Jun 18, 2026
2888c11
fix fuzzer
ealmloff Jun 18, 2026
a41b765
always derive debug
ealmloff Jun 18, 2026
234a63a
fix some hydration issues; split up rsx at build time if it is too large
ealmloff Jun 18, 2026
63d4556
fuzzing passes
ealmloff Jun 18, 2026
9e6cd46
fix fullstack playwright test
ealmloff Jun 18, 2026
1774802
more hydration fixes
ealmloff Jun 18, 2026
35ce1bd
add explicit test for textarea
ealmloff Jun 19, 2026
2f4584e
always create the typed rsx once
ealmloff Jun 19, 2026
e03000d
more cleanup
ealmloff Jun 19, 2026
808dfab
make callbody constructor private so templates are always split
ealmloff Jun 19, 2026
7b4e1c1
less rambly comments
ealmloff Jun 19, 2026
563d676
fix rsx splitting
ealmloff Jun 19, 2026
202c081
remove DynamicViewValues
ealmloff Jun 19, 2026
90942d9
fix examples
ealmloff Jun 19, 2026
922776e
undo readme changes
ealmloff Jun 19, 2026
12c7c4d
input -> search signal
ealmloff Jun 19, 2026
5b2b359
clean up websocket chat
ealmloff Jun 19, 2026
1a1fa2a
clean up set_attribute
ealmloff Jun 19, 2026
884749c
web import cleanup
ealmloff Jun 19, 2026
686910c
remove extra error boundary hydration logic
ealmloff Jun 19, 2026
47f7b07
directly hydrate
ealmloff Jun 19, 2026
43cfccc
remove useless check in fragment children
ealmloff Jun 19, 2026
93aa799
fix web mutations
ealmloff Jun 19, 2026
66b682f
clean up ssr tests
ealmloff Jun 19, 2026
7d93d05
remove decoded ops
ealmloff Jun 19, 2026
dc4170b
remove template type aliases
ealmloff Jun 19, 2026
1afca11
simplify single text node extraction
ealmloff Jun 19, 2026
d635a16
remove temp playwright test
ealmloff Jun 19, 2026
ce130cd
clean up unused args
ealmloff Jun 19, 2026
d109666
mirror error hydration on main
ealmloff Jun 19, 2026
1a5514f
only emit one component builder
ealmloff Jun 19, 2026
90f090a
remove parent arg
ealmloff Jun 19, 2026
331517b
handle many roots and force component builder
ealmloff Jun 19, 2026
0338f11
remove unused storage limits
ealmloff Jun 19, 2026
1a2187f
generate completions enum for elements similar to components
ealmloff Jun 19, 2026
0bbe4d4
more diffing cleanup
ealmloff Jun 19, 2026
1c82a7d
fix autoformatting split rsx blocks
ealmloff Jun 19, 2026
3d58147
revert handle_close_requested
ealmloff Jun 19, 2026
ea2a64e
partial restore ssr
ealmloff Jun 19, 2026
e284e02
drive remove the dom from the webview instance
ealmloff Jun 19, 2026
d7e1620
remove binary size bloating inlines
ealmloff Jun 19, 2026
640a967
rename len -> depth
ealmloff Jun 19, 2026
361d07c
remove template counts
ealmloff Jun 19, 2026
e648081
fix css module
ealmloff Jun 19, 2026
e2d0bf6
fix ssr tests
ealmloff Jun 19, 2026
b229de0
slightly clean up suspense
ealmloff Jun 19, 2026
8de4c36
even more tests
ealmloff Jun 19, 2026
c68db64
add all anchors to the heap immediately instead of defering
ealmloff Jun 19, 2026
8485f7f
DomAnchor -> InsertionSite
ealmloff Jun 19, 2026
bd0e7f3
fix event test
ealmloff Jun 19, 2026
2abc222
remove out of date todo
ealmloff Jun 19, 2026
b9e34a9
walk both attributes and nodes at the same time and pull out tree-sha…
ealmloff Jun 22, 2026
7b2fbc3
hide more of template core
ealmloff Jun 22, 2026
80a3e80
fix suspense test
ealmloff Jun 22, 2026
3ab67d7
don't eagerly collect children
ealmloff Jun 22, 2026
5121786
remove unused _escape_text
ealmloff Jun 22, 2026
766e806
match main eval order for borrow checking compatibility
ealmloff Jun 22, 2026
2dd40f6
fix clippy
ealmloff Jun 22, 2026
65c7e2b
less index based template apis
ealmloff Jun 22, 2026
0b82273
remove validate_anchors
ealmloff Jun 22, 2026
a5ae1b3
update a couple of tests
ealmloff Jun 22, 2026
a116a84
docsite hydration edge case
ealmloff Jun 22, 2026
c1ae32e
fix ssr example
ealmloff Jun 22, 2026
72a399d
fix diagnostics tests
ealmloff Jun 22, 2026
7a58920
remove mutation helpers
ealmloff Jun 22, 2026
33002f8
fix suspense template caching
ealmloff Jun 22, 2026
fae4b0c
hide template cache capability
ealmloff Jun 22, 2026
fdef63e
clean up some comments in core
ealmloff Jun 22, 2026
7d11fa7
fix formatting
ealmloff Jun 22, 2026
626d9c5
fix tests
ealmloff Jun 22, 2026
1e0d156
use a single box for mounted slots
ealmloff Jun 22, 2026
db43945
restore pop effect
ealmloff Jun 22, 2026
43785f8
remove with children
ealmloff Jun 22, 2026
c5c1345
trait based html extension
ealmloff Jun 23, 2026
6d0834e
fix path leftovers
ealmloff Jun 23, 2026
f71b749
simplify op hash
ealmloff Jun 23, 2026
9f0199f
remove EffectiveAttribute from core
ealmloff Jun 23, 2026
7ccdf69
remove DynamicNodeSlot
ealmloff Jun 23, 2026
ed090ef
prefer new/old instead of left/right
ealmloff Jun 23, 2026
56bb7cb
remove DynamicValue
ealmloff Jun 23, 2026
e288a3f
switch to anchor based iterator
ealmloff Jun 23, 2026
221e292
remove reserve logic
ealmloff Jun 23, 2026
4d38d04
update some old tests
ealmloff Jun 23, 2026
c10d107
roots are always anchors
ealmloff Jun 23, 2026
b4c68a3
lower templates lazily in debug
ealmloff Jun 23, 2026
3df1e02
less special root anchor logic
ealmloff Jun 23, 2026
1fc7036
remove pop_id
ealmloff Jun 23, 2026
bec1db8
finish removing pop id
ealmloff Jun 23, 2026
0fe2a76
always print err
ealmloff Jun 23, 2026
ecb0bc7
less root specific logic
ealmloff Jun 23, 2026
d1a3741
fix clippy in playwright tests
ealmloff Jun 23, 2026
7aed675
clean up some attribute comments
ealmloff Jun 23, 2026
998c2e8
formatting
ealmloff Jun 23, 2026
00c2dbb
push id once
ealmloff Jun 23, 2026
133ed39
simplify document element traversal
ealmloff Jun 23, 2026
b6351c5
move some fuzzer only helpers from public template api into private f…
ealmloff Jun 23, 2026
57887a8
fuzzing passes
ealmloff Jun 23, 2026
23df255
don't queue vcomponents
ealmloff Jun 23, 2026
c016c95
fix list placement
ealmloff Jun 23, 2026
395fdc8
clean up html macro
ealmloff Jun 23, 2026
c6223d1
clean up placement.rs
ealmloff Jun 23, 2026
bab4817
remove all references to dioxus_elements
ealmloff Jun 23, 2026
c36d878
remove window id from poll
ealmloff Jun 23, 2026
037401a
more waker cleanup
ealmloff Jun 23, 2026
d1f3475
remove mountref
ealmloff Jun 23, 2026
2d21ac0
revert fullstack document changes
ealmloff Jun 23, 2026
b2da413
placement resolver
ealmloff Jun 23, 2026
4bb91ba
fix document test
ealmloff Jun 23, 2026
bb37239
use props macro in window component
ealmloff Jun 23, 2026
7cad1b3
split up webview and desktop context
ealmloff Jun 24, 2026
47c23c4
fix autocomplete for attributes - RA can't see through nested macros
ealmloff Jun 24, 2026
62f7294
remove SerializedTemplate
ealmloff Jun 24, 2026
b256288
windowless desktop apps
ealmloff Jun 24, 2026
dc6b28b
document define_elements
ealmloff Jun 24, 2026
23b90e3
dynidx is only used for templates
ealmloff Jun 24, 2026
94fc050
only remove data-dioxus-id after the listener is removed
ealmloff Jun 24, 2026
bedb098
move stats into its own file
ealmloff Jun 24, 2026
24c2cc8
clean up redundant core checks
ealmloff Jun 24, 2026
4186de9
remove reuse existing mounts
ealmloff Jun 24, 2026
75f4566
remove op based search
ealmloff Jun 24, 2026
66bd7e8
never use existing mounts
ealmloff Jun 24, 2026
0db8cbc
remove find_last_element
ealmloff Jun 24, 2026
0c4a835
remove secondary component_windows map
ealmloff Jun 24, 2026
e1b210e
move stats to rsx
ealmloff Jun 24, 2026
03a2211
ssr now has zero hydration specific behavior
ealmloff Jun 24, 2026
cdcf351
don't double parse attributes
ealmloff Jun 24, 2026
ff52ae5
remove parent: node from hydration cursor - rely on the stack
ealmloff Jun 24, 2026
b7b9c29
remove some cruft in rsx
ealmloff Jun 24, 2026
83d36c6
fix fuzzing
ealmloff Jun 24, 2026
74c8d23
non-allocating utf16_len
ealmloff Jun 24, 2026
312750f
add dioxus macro to desktop
ealmloff Jun 24, 2026
8ba6e7c
clean up diff context
ealmloff Jun 24, 2026
6e22537
more context cleanup
ealmloff Jun 24, 2026
673dbfb
clean up some top level comments
ealmloff Jun 24, 2026
55bf676
remove StaticViewTemplateWithCapacity
ealmloff Jun 24, 2026
cc6b913
less new types in mount
ealmloff Jun 24, 2026
6340db6
restore hidden on suspense builder
ealmloff Jun 24, 2026
7c396c9
remove suspense fallback hydration
ealmloff Jun 24, 2026
ea91059
less public api surface for ComponentBuilder on unit components
ealmloff Jun 24, 2026
e67ea88
keep suspense closer to main
ealmloff Jun 25, 2026
234bb3b
less example changes
ealmloff Jun 25, 2026
98d282b
simplify suspense
ealmloff Jun 25, 2026
61dbdfb
move more view logic into the macro
ealmloff Jun 25, 2026
a09956d
clean up nodes.rs
ealmloff Jun 25, 2026
a554988
remove debug assertions check root wrapper
ealmloff Jun 25, 2026
b824ef6
don't change global context
ealmloff Jun 25, 2026
5b4f5d8
remove error anchor
ealmloff Jun 25, 2026
c6e62c0
remove suspense_boundary: RefCell<Option<SuspenseContext>>,
ealmloff Jun 25, 2026
8e4b1ec
fix web hydration
ealmloff Jun 25, 2026
7aeb9b2
fix hydration call
ealmloff Jun 25, 2026
b4322ec
remove double height
ealmloff Jun 25, 2026
a633dff
remove reset_renderer_cache
ealmloff Jun 25, 2026
31553a6
nodes.rs cleanup
ealmloff Jun 25, 2026
0169b3c
document PackedMountedSlot
ealmloff Jun 25, 2026
18a4a18
fix tests
ealmloff Jun 25, 2026
489c293
store the iterator position on the mount instead of searching
ealmloff Jun 25, 2026
1fb97d3
clean up a couple redundant checks
ealmloff Jun 25, 2026
69b3402
remove a couple expects
ealmloff Jun 25, 2026
6eb2033
clean up event bubbling
ealmloff Jun 25, 2026
e14a08c
remove current_render_target
ealmloff Jun 25, 2026
e950a03
remove ScopeStackFrame
ealmloff Jun 25, 2026
2f626ac
follow reverse order like main
ealmloff Jun 25, 2026
0e34e16
clean up some single caller wrappers
ealmloff Jun 25, 2026
de320f1
fix clippy
ealmloff Jun 25, 2026
8771075
fix ci
ealmloff Jun 26, 2026
6b923d2
more doc fixes
ealmloff Jun 26, 2026
8f91ac9
match hydration order to core
ealmloff Jun 26, 2026
73f7cf0
fix formatting
ealmloff Jun 26, 2026
2d3026d
fix suspense render mount
ealmloff Jun 26, 2026
80c3fb4
bump windows hot patch timeout
ealmloff Jun 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 76 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ resolver = "2"
members = [
"packages/dioxus",
"packages/core",
"packages/core-template",
"packages/oracle",
"packages/fuzz",
"packages/core-types",
"packages/cli",
"packages/cli-config",
Expand Down Expand Up @@ -37,6 +40,7 @@ members = [
"packages/signals",
"packages/stores",
"packages/stores-macro",
"packages/dioxus-const-vec",
"packages/const-serialize",
"packages/const-serialize-macro",
"packages/dx-wire-format",
Expand All @@ -63,6 +67,7 @@ members = [
"packages/playwright-tests/fullstack-spread",
"packages/playwright-tests/fullstack-routing",
"packages/playwright-tests/fullstack-hydration-order",
"packages/playwright-tests/markerless-hydration-edges",
"packages/playwright-tests/suspense-carousel",
"packages/playwright-tests/nested-suspense",
"packages/playwright-tests/cli-optimization",
Expand Down Expand Up @@ -120,6 +125,8 @@ version = "0.8.0-alpha.0"
[workspace.dependencies]
dioxus = { path = "packages/dioxus", version = "0.8.0-alpha.0" }
dioxus-core = { path = "packages/core", version = "0.8.0-alpha.0" }
dioxus-core-template = { path = "packages/core-template", version = "0.8.0-alpha.0" }
dioxus-renderer-oracle = { path = "packages/oracle", version = "0.8.0-alpha.0" }
dioxus-core-types = { path = "packages/core-types", version = "0.8.0-alpha.0" }
dioxus-core-macro = { path = "packages/core-macro", version = "0.8.0-alpha.0" }
dioxus-config-macro = { path = "packages/config-macro", version = "0.8.0-alpha.0" }
Expand Down Expand Up @@ -181,6 +188,7 @@ manganis-core = { path = "packages/manganis/manganis-core", version = "0.8.0-alp
manganis-macro = { path = "packages/manganis/manganis-macro", version = "0.8.0-alpha.0" }

# const-serialize
dioxus-const-vec = { path = "packages/dioxus-const-vec", version = "0.8.0-alpha.0" }
const-serialize = { path = "packages/const-serialize", version = "0.8.0-alpha.0" }
const-serialize-macro = { path = "packages/const-serialize-macro", version = "0.8.0-alpha.0" }

Expand Down Expand Up @@ -397,6 +405,12 @@ incremental = true
[profile.dev.package.walrus]
opt-level = 3

# Keep debug assertions for fuzzing, but compile the reusable fuzzer crate
# with release-style optimizations. (The libFuzzer binary `dioxus-fuzz` lives
# in its own sub-workspace under packages/fuzz/fuzz and sets its own profile.)
[profile.dev.package.dioxus-vdom-fuzz]
opt-level = 3

# ensure we have adversarial setup for tls
[profile.dev.package.cross-tls-crate]
opt-level = 2
Expand Down Expand Up @@ -1070,6 +1084,11 @@ name = "web_component"
path = "examples/09-reference/web_component.rs"
doc-scrape-examples = true

[[example]]
name = "custom_element"
path = "examples/09-reference/custom_element.rs"
doc-scrape-examples = true

[[example]]
name = "generic_component"
path = "examples/09-reference/generic_component.rs"
Expand All @@ -1090,6 +1109,11 @@ name = "optional_props"
path = "examples/09-reference/optional_props.rs"
doc-scrape-examples = true

[[example]]
name = "html_builder"
path = "examples/09-reference/html_builder.rs"
doc-scrape-examples = true

[[example]]
name = "rsx_usage"
path = "examples/09-reference/rsx_usage.rs"
Expand Down
1 change: 0 additions & 1 deletion examples/01-app-demos/hackernews/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
num::ParseIntError,
str::FromStr,
};
use svg_attributes::to;

fn main() {
LaunchBuilder::new()
Expand Down
63 changes: 51 additions & 12 deletions examples/08-apis/multiwindow.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,71 @@
//! Multiwindow example
//!
//! This example shows how to implement a simple multiwindow application using dioxus.
//! This works by spawning a new window when the user clicks a button. We have to build a new virtualdom which has its
//! own context, root elements, etc.
//! The app root owns each native window explicitly.

use dioxus::desktop::{Config, WindowBuilder, WindowConfig};
use dioxus::prelude::*;

fn main() {
dioxus::launch(app);
dioxus::LaunchBuilder::desktop()
.with_cfg(Config::new().with_headless_root(true))
Comment thread
ealmloff marked this conversation as resolved.
.launch(app);
}

fn app() -> Element {
let onclick = move |_| {
dioxus::desktop::window().new_window(VirtualDom::new(popup), Default::default());
};
let mut window_state = use_store(|| WindowState {
windows: vec![0],
next_id: 1,
count: 0,
});

rsx! {
button { onclick, "New Window" }
for id in window_state.windows().read().iter().copied() {
Window {
key: "{id}",
config: WindowConfig::new().with_window(
WindowBuilder::new().with_title(format!("Window {id}"))
),
onclose: move |_| window_state.close_window(id),
AppWindow { id, window_state }
}
}
}
}

#[derive(Store, PartialEq, Clone, Debug)]
struct WindowState {
windows: Vec<usize>,
next_id: usize,
count: usize,
}

#[store]
impl Store<WindowState> {
fn open_window(&mut self) {
let id = self.next_id().cloned();
self.next_id().set(id + 1);
self.windows().push(id);
}

fn close_window(&mut self, id: usize) {
self.windows().retain(|window_id| *window_id != id);
}

fn increment_count(&mut self) {
let count = self.count().cloned();
self.count().set(count + 1);
}
}

fn popup() -> Element {
let mut count = use_signal(|| 0);
#[component]
fn AppWindow(id: usize, mut window_state: Store<WindowState>) -> Element {
rsx! {
div {
h1 { "Popup Window" }
p { "Count: {count}" }
button { onclick: move |_| count += 1, "Increment" }
h1 { "Window {id}" }
p { "Count: {window_state.count()}" }
button { onclick: move |_| window_state.increment_count(), "Increment" }
button { onclick: move |_| window_state.open_window(), "New Window" }
}
}
}
20 changes: 16 additions & 4 deletions examples/08-apis/multiwindow_with_tray_icon.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! Multiwindow with tray icon example
//!
//! This example shows how to implement a simple multiwindow application and tray icon using dioxus.
//! This works by spawning a new window when the user clicks a button. We have to build a new virtualdom which has its
//! own context, root elements, etc.
//! This works by rendering a `Window` component when the user clicks a button.
//!
//! This is useful for apps that incorporate settings panels or persistent windows like Raycast.

Expand All @@ -18,6 +17,9 @@ fn main() {
}

fn app() -> Element {
let mut windows = use_signal(Vec::<usize>::new);
let mut next_id = use_signal(|| 0usize);

use_hook(|| {
// Set the close behavior for the main window
// This will hide the window instead of closing it when the user clicks the close button
Expand All @@ -31,14 +33,24 @@ fn app() -> Element {
rsx! {
button {
onclick: move |_| {
window().new_window(VirtualDom::new(popup), Default::default());
let id = next_id();
next_id.set(id + 1);
windows.write().push(id);
},
"New Window"
}
for id in windows() {
Window {
key: "{id}",
onclose: move |_| windows.write().retain(|window_id| *window_id != id),
Popup {}
}
}
}
}

fn popup() -> Element {
#[component]
fn Popup() -> Element {
rsx! {
div { "This is a popup window!" }
}
Expand Down
2 changes: 1 addition & 1 deletion examples/08-apis/on_resize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! perform layout and painting.

use dioxus::prelude::*;
use dioxus_elements::geometry::euclid::Size2D;
use dioxus_html::geometry::euclid::Size2D;

fn main() {
dioxus::launch(app);
Expand Down
Loading
Loading