Skip to content

Commit 94a1016

Browse files
Merge pull request #114 from hymm/stage-yeet-fix-sub-app-example
fix sub app example
2 parents ee7b0a6 + 096fbdd commit 94a1016

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

crates/bevy_app/src/app.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Debug for App {
9797
/// # Example
9898
///
9999
/// ```rust
100-
/// # use bevy_app::{App, AppLabel, SubApp};
100+
/// # use bevy_app::{App, AppLabel, SubApp, CoreSchedule};
101101
/// # use bevy_ecs::prelude::*;
102102
/// # use bevy_ecs::scheduling::ScheduleLabel;
103103
///
@@ -107,26 +107,28 @@ impl Debug for App {
107107
/// #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, AppLabel)]
108108
/// struct ExampleApp;
109109
///
110-
/// #[derive(Debug, Hash, PartialEq, Eq, Clone, ScheduleLabel)]
111-
/// struct ExampleSchedule;
112-
///
113-
/// let mut app = App::empty();
110+
/// let mut app = App::new();
111+
///
114112
/// // initialize the main app with a value of 0;
115113
/// app.insert_resource(Val(10));
116114
///
117115
/// // create a app with a resource and a single schedule
118116
/// let mut sub_app = App::empty();
117+
/// // add an outer schedule that runs the main schedule
118+
/// sub_app.add_simple_outer_schedule();
119119
/// sub_app.insert_resource(Val(100));
120-
/// let mut example_schedule = Schedule::new();
121-
/// example_schedule.add_system(|counter: Res<Val>| {
120+
///
121+
/// // initialize main schedule
122+
/// sub_app.init_schedule(CoreSchedule::Main);
123+
/// sub_app.add_system(|counter: Res<Val>| {
122124
/// // since we assigned the value from the main world in extract
123125
/// // we see that value instead of 100
124126
/// assert_eq!(counter.0, 10);
125127
/// });
126-
/// sub_app.add_schedule(ExampleSchedule, example_schedule);
127-
///
128+
///
128129
/// // add the sub_app to the app
129130
/// app.insert_sub_app(ExampleApp, SubApp::new(sub_app, |main_world, sub_app| {
131+
/// // extract the value from the main app to the sub app
130132
/// sub_app.world.resource_mut::<Val>().0 = main_world.resource::<Val>().0;
131133
/// }));
132134
///

0 commit comments

Comments
 (0)