1
1
use std:: sync:: OnceLock ;
2
2
3
3
use crate :: {
4
- ActionId , ActionMeta , ActionWithMeta , Effects , EnablingCondition , Instant , Reducer , SystemTime ,
5
- TimeService , SubStore ,
4
+ ActionId , ActionMeta , ActionWithMeta , Effects , EnablingCondition , Instant , Reducer , SubStore ,
5
+ SystemTime , TimeService ,
6
6
} ;
7
7
8
8
/// Wraps around State and allows only immutable borrow,
@@ -158,7 +158,10 @@ where
158
158
<Self as SubStore < State , S > >:: SubAction : Into < Action > ,
159
159
Self : SubStore < State , S > ,
160
160
{
161
- if !action. is_enabled ( <Self as SubStore < State , S > >:: state ( self ) , self . last_action_id . into ( ) ) {
161
+ if !action. is_enabled (
162
+ <Self as SubStore < State , S > >:: state ( self ) ,
163
+ self . last_action_id . into ( ) ,
164
+ ) {
162
165
return false ;
163
166
}
164
167
self . dispatch_enabled ( action. into ( ) . into ( ) ) ;
@@ -172,12 +175,16 @@ where
172
175
let time_passed = monotonic_time
173
176
. duration_since ( self . monotonic_time )
174
177
. as_nanos ( ) ;
178
+ self . monotonic_time = monotonic_time;
179
+
175
180
let prev = self . last_action_id ;
176
- self . last_action_id = prev. next ( time_passed as u64 ) ;
177
- self . recursion_depth += 1 ;
181
+ let curr = prev. next ( time_passed as u64 ) ;
178
182
179
183
let action_with_meta =
180
- ActionMeta :: new ( self . last_action_id , prev, self . recursion_depth ) . with_action ( action) ;
184
+ ActionMeta :: new ( curr, prev, self . recursion_depth ) . with_action ( action) ;
185
+
186
+ self . last_action_id = curr;
187
+ self . recursion_depth += 1 ;
181
188
182
189
self . dispatch_reducer ( & action_with_meta) ;
183
190
self . dispatch_effects ( action_with_meta) ;
0 commit comments