diff --git a/examples/counter.rs b/examples/counter.rs index 96ea46450..fa597a03b 100644 --- a/examples/counter.rs +++ b/examples/counter.rs @@ -41,6 +41,5 @@ fn app_logic(data: &mut AppData) -> impl View { } pub fn main() { - let app = App::new(AppData::default(), app_logic); - AppLauncher::new(app).run(); + App::new(AppData::default(), app_logic).run() } diff --git a/examples/scroll.rs b/examples/scroll.rs index 54fac4d30..1946a8f61 100644 --- a/examples/scroll.rs +++ b/examples/scroll.rs @@ -33,6 +33,5 @@ fn app_logic(_: &mut ()) -> impl View<()> { } fn main() { - let app = App::new((), app_logic); - AppLauncher::new(app).run(); + App::new((), app_logic).run() } diff --git a/src/app.rs b/src/app.rs index c7c940cd1..9e7ea2d93 100644 --- a/src/app.rs +++ b/src/app.rs @@ -25,6 +25,7 @@ use tokio::runtime::Runtime; use crate::event::{AsyncWake, EventResult}; use crate::id::IdPath; use crate::widget::{CxState, EventCx, LayoutCx, PaintCx, Pod, UpdateCx, WidgetState}; +use crate::AppLauncher; use crate::{ event::Event, id::Id, @@ -271,6 +272,20 @@ where false } } + + /// Runs the app inside a window. + /// + /// This is a thin convinience wrapper around [AppLauncher](xilem::AppLauncher) + pub fn run_with_title(self, title: impl Into) { + AppLauncher::new(self).title(title).run() + } + + /// Runs the app inside a window. + /// + /// This is a thin convinience wrapper around [AppLauncher](xilem::AppLauncher) + pub fn run(self) { + AppLauncher::new(self).run() + } } impl> App { diff --git a/src/main.rs b/src/main.rs index b3a8fcd56..b913998e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use xilem::{button, App, AppLauncher, View}; +use xilem::{button, App, View}; fn app_logic(_data: &mut ()) -> impl View<()> { button("click me", |_| println!("clicked")) @@ -15,6 +15,5 @@ fn main() { window_handle.show(); app.run(None); */ - let app = App::new((), app_logic); - AppLauncher::new(app).run() + App::new((), app_logic).run() }