Skip to content

Commit

Permalink
Document
Browse files Browse the repository at this point in the history
  • Loading branch information
nanoqsh committed Jun 9, 2024
1 parent 69cd1c6 commit 02f0ead
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ let draw = {
// Create a black RGBA background
let bg = Rgba::from_bytes([0, 0, 0, !0]);

// Lazily create a layer
// Lazily initialize a layer
let layer = layer.get_or_init(|| cx.make_layer(&shader, frame.format()));

frame
Expand Down
4 changes: 4 additions & 0 deletions dunge/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ impl<V> WindowState<V> {
}
}

/// Runs an event loop.
pub fn run<U>(self, cx: Context, upd: U) -> Result<(), LoopError>
where
U: Update<Event = V> + 'static,
{
el::run(self, cx, upd)
}

/// Locally runs an event loop.
#[cfg(not(target_arch = "wasm32"))]
pub fn run_local<U>(self, cx: Context, upd: U) -> Result<(), LoopError>
where
Expand All @@ -106,11 +108,13 @@ impl<V> WindowState<V> {
}
}

/// Creates a new [`WindowState`].
#[cfg(all(feature = "winit", not(target_arch = "wasm32")))]
pub fn window<V>() -> WindowState<V> {
state(Element(()))
}

/// Creates a [`WindowState`] from an HTML element.
#[cfg(all(feature = "winit", target_arch = "wasm32"))]
pub fn from_element(id: &str) -> WindowState {
use web_sys::Window;
Expand Down
2 changes: 1 addition & 1 deletion examples/window/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async fn run() -> Result<(), Error> {
// Create a black RGBA background
let bg = Rgba::from_bytes([0, 0, 0, !0]);

// Lazily create a layer
// Lazily initialize a layer
let layer = layer.get_or_init(|| cx.make_layer(&shader, frame.format()));

frame
Expand Down

0 comments on commit 02f0ead

Please sign in to comment.