don't expose the signal scope subscriber API publicly

This commit is contained in:
Evan Almloff committed 2024-02-05 08:13:52 -06:00
1 parent 30bac267c9
commit 91fea15cdc
4 files changed
+18 -7

No files matched your search

+14 -3
View File
@@ -22,9 +22,20 @@ thread_local! {
static CURRENT: RefCell<Vec<ReactiveContext>> = const { RefCell::new(vec![]) };
}
impl Default for ReactiveContext {
fn default() -> Self {
Self::new_for_scope(None)
}
}
impl ReactiveContext {
/// Create a new reactive context
pub fn new(scope: Option<ScopeId>) -> Self {
pub fn new() -> Self {
Self::default()
}
/// Create a new reactive context that may update a scope
pub(crate) fn new_for_scope(scope: Option<ScopeId>) -> Self {
let (tx, rx) = flume::unbounded();
let mut scope_subscribers = FxHashSet::default();
@@ -56,7 +67,7 @@ impl ReactiveContext {
///
/// If this was set manually, then that value will be returned.
///
/// If there's no current reactive context, then a new one will be created at the current scope and returned.
/// If there's no current reactive context, then a new one will be created for the current scope and returned.
pub fn current() -> Self {
let cur = CURRENT.with(|current| current.borrow().last().cloned());
@@ -71,7 +82,7 @@ impl ReactiveContext {
}
// Otherwise, create a new context at the current scope
provide_context(ReactiveContext::new(current_scope_id()))
provide_context(ReactiveContext::new_for_scope(current_scope_id()))
}
/// Run this function in the context of this reactive context