Skip to content

Commit eedf860

Browse files
committed
allow specifying schedule
2 parents 6b36158 + 1c5cf5a commit eedf860

File tree

9 files changed

+104
-36
lines changed

9 files changed

+104
-36
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ the format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
44

55
## unreleased
66

7+
# 0.3.2 (2025-11-28)
8+
9+
### added
10+
11+
- allow specifying custom schedule for the `JonmoPlugin`
12+
713
# 0.4.1 (2025-11-27)
814

915
### fixed

Cargo.lock

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "jonmo"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
edition = "2024"
55
categories = ["asynchronous", "gui", "game-development"]
66
description = "ergonomic Bevy-native reactivity powered by FRP signals"

examples/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub(crate) fn examples_plugin(app: &mut App) {
169169
}),
170170
..default()
171171
}),
172-
JonmoPlugin,
172+
JonmoPlugin::default(),
173173
#[cfg(feature = "debug")]
174174
DebugUiPlugin,
175175
))

src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ mod tests {
712712
fn create_test_app() -> App {
713713
cleanup();
714714
let mut app = App::new();
715-
app.add_plugins((MinimalPlugins, JonmoPlugin));
715+
app.add_plugins((MinimalPlugins, JonmoPlugin::default()));
716716
app
717717
}
718718

src/lib.rs

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
extern crate alloc;
1010

1111
use bevy_app::prelude::*;
12-
use bevy_ecs::prelude::*;
12+
use bevy_ecs::{
13+
prelude::*,
14+
schedule::{InternedScheduleLabel, ScheduleLabel},
15+
};
1316

1417
#[cfg(feature = "builder")]
1518
pub mod builder;
@@ -21,8 +24,67 @@ pub mod signal_vec;
2124
pub mod utils;
2225

2326
/// Includes the systems required for [jonmo](crate) to function.
24-
#[derive(Default)]
25-
pub struct JonmoPlugin;
27+
///
28+
/// # Example
29+
///
30+
/// ```rust
31+
/// use bevy_app::prelude::*;
32+
/// use bevy_ecs::prelude::*;
33+
/// use jonmo::{SignalProcessing, prelude::*};
34+
///
35+
/// let mut app = App::new();
36+
/// // Use default configuration (runs in Last schedule)
37+
/// app.add_plugins(JonmoPlugin::default());
38+
///
39+
/// let mut app = App::new();
40+
/// // Or customize the schedule
41+
/// app.add_plugins(JonmoPlugin::new().in_schedule(PostUpdate));
42+
///
43+
/// // Add ordering constraints using configure_sets
44+
/// # #[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
45+
/// # struct SystemSet1;
46+
///
47+
/// # #[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
48+
/// # struct SystemSet2;
49+
///
50+
/// app.configure_sets(
51+
/// PostUpdate,
52+
/// SignalProcessing.before(SystemSet1).before(SystemSet2),
53+
/// );
54+
/// ```
55+
pub struct JonmoPlugin {
56+
schedule: InternedScheduleLabel,
57+
}
58+
59+
impl Default for JonmoPlugin {
60+
fn default() -> Self {
61+
Self {
62+
schedule: Last.intern(),
63+
}
64+
}
65+
}
66+
67+
impl JonmoPlugin {
68+
/// Create a new `JonmoPlugin` with signal processing running in the `Last` schedule.
69+
pub fn new() -> Self {
70+
Self::default()
71+
}
72+
73+
/// Specify which schedule the signal processing systems should run in.
74+
///
75+
/// # Example
76+
///
77+
/// ```rust
78+
/// use bevy_app::prelude::*;
79+
/// use jonmo::prelude::*;
80+
///
81+
/// JonmoPlugin::new().in_schedule(Update);
82+
/// ```
83+
pub fn in_schedule(mut self, schedule: impl ScheduleLabel) -> Self {
84+
self.schedule = schedule.intern();
85+
self
86+
}
87+
}
2688

2789
/// [`SystemSet`] that can be used to schedule systems around signal processing.
2890
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
@@ -31,7 +93,7 @@ pub struct SignalProcessing;
3193
impl Plugin for JonmoPlugin {
3294
fn build(&self, app: &mut App) {
3395
app.add_systems(
34-
Last,
96+
self.schedule,
3597
(
3698
(
3799
signal_vec::trigger_replays::<signal_vec::VecReplayTrigger>,

src/signal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,7 @@ mod tests {
22702270

22712271
fn create_test_app() -> App {
22722272
let mut app = App::new();
2273-
app.add_plugins((MinimalPlugins, JonmoPlugin));
2273+
app.add_plugins((MinimalPlugins, JonmoPlugin::default()));
22742274
app.register_type::<TestData>();
22752275
app
22762276
}
@@ -3121,7 +3121,7 @@ mod tests {
31213121
#[test]
31223122
fn test_throttle() {
31233123
let mut app = App::new();
3124-
app.add_plugins((MinimalPlugins.build().disable::<TimePlugin>(), JonmoPlugin));
3124+
app.add_plugins((MinimalPlugins.build().disable::<TimePlugin>(), JonmoPlugin::default()));
31253125
app.init_resource::<Time>(); // manually managing time for the test
31263126
app.init_resource::<SignalOutput<i32>>();
31273127

src/signal_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ pub(crate) mod tests {
14531453
fn create_test_app() -> App {
14541454
cleanup(true);
14551455
let mut app = App::new();
1456-
app.add_plugins((MinimalPlugins, JonmoPlugin));
1456+
app.add_plugins((MinimalPlugins, JonmoPlugin::default()));
14571457
app
14581458
}
14591459

src/signal_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4063,7 +4063,7 @@ pub(crate) mod tests {
40634063
fn create_test_app() -> App {
40644064
cleanup(true);
40654065
let mut app = App::new();
4066-
app.add_plugins((MinimalPlugins, JonmoPlugin));
4066+
app.add_plugins((MinimalPlugins, JonmoPlugin::default()));
40674067
app
40684068
}
40694069

0 commit comments

Comments
 (0)