Skip to main content

HostSubscriber

Struct HostSubscriber 

Source
pub struct HostSubscriber { /* private fields */ }
Expand description

宿主级订阅者:由窗口宿主显式创建并绑定到一棵树的 reactive scope。

与 Element 内部 subscriber 的区别:它不对应任何 element,只用于在 build_root 里读取 Signal / Memo 建立依赖,让后续变化只脏到本窗口 的 scope。宿主在 on_about_to_wait 用 has_dirty() 决定 rebuild, 帧循环再按 scope 排空,避免跨窗口互相吞 dirty 或退回全局 epoch。

Implementations§

Source§

impl HostSubscriber

Source

pub fn new(scope: u64) -> Self

绑定到一个明确的 reactive scope(通常取 ElementTree::reactive_scope())。

Source

pub fn id(&self) -> SubscriberId

Source

pub fn with<T>(&self, f: impl FnOnce() -> T) -> T

在该订阅者上下文中读取信号;块内的 Signal::get() / Memo::get() 归它所有。

Source

pub fn rebind<T>(&self, f: impl FnOnce() -> T) -> T

重新绑定依赖:换 generation,上一轮依赖在下一次通知时自然失效。

条件分支变化导致这次少读某个信号时必须调用,避免旧依赖永久残留。

Source

pub fn has_dirty(&self) -> bool

只读检查:本订阅者是否因上游变化被标脏(不消费 dirty)。

Source

pub fn scope(&self) -> u64

Trait Implementations§

Source§

impl Debug for HostSubscriber

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for HostSubscriber

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.