Cleanup
This commit is contained in:
@@ -1363,10 +1363,6 @@ pub fn use_effect(effect: impl Fn() + 'static) {
|
||||
with_hook_slot(|| ruin_reactivity::effect(effect), |_| ());
|
||||
}
|
||||
|
||||
pub fn flush_reactive_updates() {
|
||||
current_reactor().flush_now();
|
||||
}
|
||||
|
||||
pub fn use_window_title(compute: impl FnOnce() -> String) {
|
||||
with_render_context_state(|context| {
|
||||
context.side_effects.borrow_mut().window_title = Some(compute());
|
||||
@@ -1580,7 +1576,6 @@ where
|
||||
let result = future.await;
|
||||
if generation.get() == next_generation {
|
||||
let _ = resource.state.replace(ResourceState::Ready(result));
|
||||
current_reactor().flush_now();
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -2058,10 +2053,10 @@ pub mod prelude {
|
||||
ContextKey, FocusScope, FontWeight, IntoBorder, IntoEdges, IntoView, Key, Memo, Mountable,
|
||||
Pending, Ready, Resource, ResourceState, Result, ScrollBoxBuilder, ScrollBoxWidget,
|
||||
Shortcut, ShortcutScope, Signal, TextBuilder, TextChildren, TextRole, TextValue, View,
|
||||
WidgetRef, Window, block, button, colors, column, component, context_provider,
|
||||
flush_reactive_updates, provide, row, scroll_box, surfaces, text, use_context, use_effect,
|
||||
use_memo, use_resource, use_shortcut, use_shortcut_with_context, use_signal,
|
||||
use_widget_ref, use_window_title, view,
|
||||
WidgetRef, Window, block, button, colors, column, component, context_provider, provide,
|
||||
row, scroll_box, surfaces, text, use_context, use_effect, use_memo, use_resource,
|
||||
use_shortcut, use_shortcut_with_context, use_signal, use_widget_ref, use_window_title,
|
||||
view,
|
||||
};
|
||||
pub use ruin_ui::{
|
||||
Border, Color, CursorIcon, Edges, Element, ElementId, InteractionTree, PointerButton,
|
||||
@@ -2632,4 +2627,27 @@ mod tests {
|
||||
|
||||
assert!(debug.contains("offset_y: 96.0"), "{debug}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn async_signal_write_flushes_without_manual_reactor_flush() {
|
||||
let signal = Signal::new("before".to_string());
|
||||
let observed = Rc::new(RefCell::new(String::new()));
|
||||
let _effect = ruin_reactivity::effect({
|
||||
let signal = signal.clone();
|
||||
let observed = Rc::clone(&observed);
|
||||
move || {
|
||||
*observed.borrow_mut() = signal.get();
|
||||
}
|
||||
});
|
||||
|
||||
ruin_runtime::queue_future({
|
||||
let signal = signal.clone();
|
||||
async move {
|
||||
let _ = signal.set("after".to_string());
|
||||
}
|
||||
});
|
||||
ruin_runtime::run_until_stalled();
|
||||
|
||||
assert_eq!(observed.borrow().as_str(), "after");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user