Skip to content

Commit 6f5a4d9

Browse files
Rename add_resource to insert_resource (#1356)
* Renamed add_resource to insert_resource * Changed usage of add_resource to insert_resource * Renamed add_thread_local_resource
1 parent b922a3e commit 6f5a4d9

39 files changed

+53
-53
lines changed

crates/bevy_app/src/app_builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,20 @@ impl AppBuilder {
210210
where
211211
T: Send + Sync + 'static,
212212
{
213-
self.add_resource(Events::<T>::default())
213+
self.insert_resource(Events::<T>::default())
214214
.add_system_to_stage(stage::EVENT, Events::<T>::update_system.system())
215215
}
216216

217-
/// Adds a resource to the current [App] and overwrites any resource previously added of the same type.
218-
pub fn add_resource<T>(&mut self, resource: T) -> &mut Self
217+
/// Inserts a resource to the current [App] and overwrites any resource previously added of the same type.
218+
pub fn insert_resource<T>(&mut self, resource: T) -> &mut Self
219219
where
220220
T: Send + Sync + 'static,
221221
{
222222
self.app.resources.insert(resource);
223223
self
224224
}
225225

226-
pub fn add_thread_local_resource<T>(&mut self, resource: T) -> &mut Self
226+
pub fn insert_thread_local_resource<T>(&mut self, resource: T) -> &mut Self
227227
where
228228
T: 'static,
229229
{

crates/bevy_asset/src/assets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl AddAsset for AppBuilder {
217217
asset_server.register_asset_type::<T>()
218218
};
219219

220-
self.add_resource(assets)
220+
self.insert_resource(assets)
221221
.add_system_to_stage(
222222
super::stage::ASSET_EVENTS,
223223
Assets::<T>::asset_event_system.system(),

crates/bevy_asset/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl Plugin for AssetPlugin {
8585

8686
let asset_server = AssetServer::with_boxed_io(source, task_pool);
8787

88-
app.add_resource(asset_server);
88+
app.insert_resource(asset_server);
8989
}
9090

9191
app.add_stage_before(

crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct FrameTimeDiagnosticsState {
1414
impl Plugin for FrameTimeDiagnosticsPlugin {
1515
fn build(&self, app: &mut bevy_app::AppBuilder) {
1616
app.add_startup_system(Self::setup_system.system())
17-
.add_resource(FrameTimeDiagnosticsState { frame_count: 0.0 })
17+
.insert_resource(FrameTimeDiagnosticsState { frame_count: 0.0 })
1818
.add_system(Self::diagnostic_system.system());
1919
}
2020
}

crates/bevy_diagnostic/src/log_diagnostics_plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Default for LogDiagnosticsPlugin {
3030

3131
impl Plugin for LogDiagnosticsPlugin {
3232
fn build(&self, app: &mut bevy_app::AppBuilder) {
33-
app.add_resource(LogDiagnosticsState {
33+
app.insert_resource(LogDiagnosticsState {
3434
timer: Timer::new(self.wait_duration, true),
3535
filter: self.filter.clone(),
3636
});

crates/bevy_gilrs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl Plugin for GilrsPlugin {
1818
.build()
1919
{
2020
Ok(gilrs) => {
21-
app.add_thread_local_resource(gilrs)
21+
app.insert_thread_local_resource(gilrs)
2222
.add_startup_system_to_stage(PRE_STARTUP, gilrs_event_startup_system.system())
2323
.add_system_to_stage(stage::PRE_EVENT, gilrs_event_system.system());
2424
}

crates/bevy_text/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl Plugin for TextPlugin {
3939
app.add_asset::<Font>()
4040
.add_asset::<FontAtlasSet>()
4141
.init_asset_loader::<FontLoader>()
42-
.add_resource(DefaultTextPipeline::default())
42+
.insert_resource(DefaultTextPipeline::default())
4343
.add_system_to_stage(bevy_app::stage::POST_UPDATE, text2d_system.system())
4444
.add_system_to_stage(
4545
bevy_render::stage::DRAW,

examples/2d/texture_atlas.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn main() {
55
App::build()
66
.init_resource::<RpgSpriteHandles>()
77
.add_plugins(DefaultPlugins)
8-
.add_resource(State::new(AppState::Setup))
8+
.insert_resource(State::new(AppState::Setup))
99
.add_stage_after(stage::UPDATE, STAGE, StateStage::<AppState>::default())
1010
.on_state_enter(STAGE, AppState::Setup, load_textures.system())
1111
.on_state_update(STAGE, AppState::Setup, check_textures.system())

examples/3d/3d_scene.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bevy::prelude::*;
22

33
fn main() {
44
App::build()
5-
.add_resource(Msaa { samples: 4 })
5+
.insert_resource(Msaa { samples: 4 })
66
.add_plugins(DefaultPlugins)
77
.add_startup_system(setup.system())
88
.run();

examples/3d/load_gltf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bevy::prelude::*;
22

33
fn main() {
44
App::build()
5-
.add_resource(Msaa { samples: 4 })
5+
.insert_resource(Msaa { samples: 4 })
66
.add_plugins(DefaultPlugins)
77
.add_startup_system(setup.system())
88
.run();

0 commit comments

Comments
 (0)