Align desktop initializer arguments with builders
This commit is contained in:
1 parent
166bac2a93
commit
18685da28b
6 files changed
+13
-13
No files matched your search
@@ -6,7 +6,5 @@ mod app;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let attributes = WindowAttributes::default().with_inner_size(LogicalSize::new(420.0, 900.0));
|
let attributes = WindowAttributes::default().with_inner_size(LogicalSize::new(420.0, 900.0));
|
||||||
DesktopApp::<DesktopUiState>::run_with_attributes(attributes, |ui_state, rsc| {
|
DesktopApp::<DesktopUiState>::run_with_attributes(attributes, app::build);
|
||||||
app::build(rsc, ui_state)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,5 @@ use iris::prelude::*;
|
|||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
DesktopApp::<DesktopUiState>::run_with(|ui_state, rsc| app::build(rsc, ui_state));
|
DesktopApp::<DesktopUiState>::run_with(app::build);
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,5 @@ use iris::prelude::*;
|
|||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
DesktopApp::<DesktopUiState>::run_with(|ui_state, rsc| app::build(rsc, ui_state));
|
DesktopApp::<DesktopUiState>::run_with(app::build);
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,5 @@ use iris::prelude::*;
|
|||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
DesktopApp::<DesktopUiState>::run_with(|ui_state, rsc| app::build(rsc, ui_state));
|
DesktopApp::<DesktopUiState>::run_with(app::build);
|
||||||
}
|
}
|
||||||
@@ -33,21 +33,23 @@ loader glue. An application with no state beyond the UI state receives
|
|||||||
```rust
|
```rust
|
||||||
use iris::prelude::*;
|
use iris::prelude::*;
|
||||||
|
|
||||||
|
fn build<Rsc: UiRsc>(rsc: &mut Rsc, ui_state: &mut impl HasRoot<Rsc>) {
|
||||||
|
rect(PaintId::RED).set_root(rsc, ui_state);
|
||||||
|
}
|
||||||
|
|
||||||
#[iris::app_init]
|
#[iris::app_init]
|
||||||
fn create(
|
fn create(
|
||||||
ui_state: &mut AndroidUiState,
|
ui_state: &mut AndroidUiState,
|
||||||
rsc: &mut StdRsc<AndroidUiState>,
|
rsc: &mut StdRsc<AndroidUiState>,
|
||||||
) {
|
) {
|
||||||
rect(PaintId::RED).set_root(rsc, ui_state);
|
build(rsc, ui_state);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Desktop has the corresponding initializer form:
|
Desktop has the corresponding initializer form:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
DesktopApp::<DesktopUiState>::run_with(|ui_state, rsc| {
|
DesktopApp::<DesktopUiState>::run_with(build);
|
||||||
rect(PaintId::RED).set_root(rsc, ui_state);
|
|
||||||
});
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Background work updates either host through the same task context. An update
|
Background work updates either host through the same task context. An update
|
||||||
|
|||||||
+3
-3
@@ -156,17 +156,17 @@ impl<State: DesktopAppState> DesktopApp<State> {
|
|||||||
|
|
||||||
impl DesktopApp<DesktopUiState> {
|
impl DesktopApp<DesktopUiState> {
|
||||||
/// Runs an application whose only state is Iris's desktop UI state.
|
/// Runs an application whose only state is Iris's desktop UI state.
|
||||||
pub fn run_with(init: impl FnOnce(&mut DesktopUiState, &mut StdRsc<DesktopUiState>) + 'static) {
|
pub fn run_with(init: impl FnOnce(&mut StdRsc<DesktopUiState>, &mut DesktopUiState) + 'static) {
|
||||||
Self::run_with_attributes(DesktopUiState::window_attributes(), init);
|
Self::run_with_attributes(DesktopUiState::window_attributes(), init);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_with_attributes(
|
pub fn run_with_attributes(
|
||||||
attributes: WindowAttributes,
|
attributes: WindowAttributes,
|
||||||
init: impl FnOnce(&mut DesktopUiState, &mut StdRsc<DesktopUiState>) + 'static,
|
init: impl FnOnce(&mut StdRsc<DesktopUiState>, &mut DesktopUiState) + 'static,
|
||||||
) {
|
) {
|
||||||
App::<Self>::run_with(move |event_loop, proxy| {
|
App::<Self>::run_with(move |event_loop, proxy| {
|
||||||
Self::new_with(event_loop, proxy, attributes, move |mut ui_state, rsc| {
|
Self::new_with(event_loop, proxy, attributes, move |mut ui_state, rsc| {
|
||||||
init(&mut ui_state, rsc);
|
init(rsc, &mut ui_state);
|
||||||
ui_state
|
ui_state
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user