pub struct Reactor<E: AbstractEntity + Filterable + Send + 'static = Entity, Ev: Clone + Send + 'static = Attested<Event>>(/* private fields */);Expand description
A Reactor is a collection of subscriptions, which are to be notified of changes to a set of entities
Implementations§
Source§impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Reactor<E, Ev>
impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Reactor<E, Ev>
pub fn new() -> Self
Sourcepub fn remove_query(
&self,
subscription_id: ReactorSubscriptionId,
query_id: QueryId,
) -> Result<(), SubscriptionError>
pub fn remove_query( &self, subscription_id: ReactorSubscriptionId, query_id: QueryId, ) -> Result<(), SubscriptionError>
Remove a predicate from a subscription
Sourcepub fn add_entity_subscriptions(
&self,
subscription_id: ReactorSubscriptionId,
entity_ids: impl IntoIterator<Item = EntityId>,
)
pub fn add_entity_subscriptions( &self, subscription_id: ReactorSubscriptionId, entity_ids: impl IntoIterator<Item = EntityId>, )
Add entity subscriptions to a subscription
Sourcepub fn remove_entity_subscriptions(
&self,
subscription_id: ReactorSubscriptionId,
entity_ids: impl IntoIterator<Item = EntityId>,
)
pub fn remove_entity_subscriptions( &self, subscription_id: ReactorSubscriptionId, entity_ids: impl IntoIterator<Item = EntityId>, )
Remove entity subscriptions from a subscription
Source§impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Reactor<E, Ev>
impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Reactor<E, Ev>
Sourcepub async fn add_query_and_notify<H: PreNotifyHook>(
&self,
subscription_id: ReactorSubscriptionId,
query_id: QueryId,
collection_id: CollectionId,
selection: Selection,
node: &dyn TNodeErased<E>,
resultset: EntityResultSet<E>,
gap_fetcher: Arc<dyn GapFetcher<E>>,
pre_notify_hook: H,
) -> Result<()>
pub async fn add_query_and_notify<H: PreNotifyHook>( &self, subscription_id: ReactorSubscriptionId, query_id: QueryId, collection_id: CollectionId, selection: Selection, node: &dyn TNodeErased<E>, resultset: EntityResultSet<E>, gap_fetcher: Arc<dyn GapFetcher<E>>, pre_notify_hook: H, ) -> Result<()>
Add a new predicate to a subscription (initial subscription only) Fails if query_id already exists - use update_query for updates
Add a query and send initialization notification (for local subscriptions) Collects ReactorUpdateItems and sends them pre_notify_hook is called before sending notification (e.g., to mark LiveQuery initialized)
Sourcepub async fn update_query_and_notify<H: PreNotifyHook>(
&self,
subscription_id: ReactorSubscriptionId,
query_id: QueryId,
collection_id: CollectionId,
selection: Selection,
node: &dyn TNodeErased<E>,
version: u32,
pre_notify_hook: H,
) -> Result<()>
pub async fn update_query_and_notify<H: PreNotifyHook>( &self, subscription_id: ReactorSubscriptionId, query_id: QueryId, collection_id: CollectionId, selection: Selection, node: &dyn TNodeErased<E>, version: u32, pre_notify_hook: H, ) -> Result<()>
Update an existing predicate (v>0) and send notifications Does diffing against the current resultset Used by local LiveQuery updates pre_notify_hook is called before sending notification (e.g., to mark LiveQuery initialized)
Sourcepub async fn notify_change<C: ChangeNotification<Entity = E, Event = Ev> + Clone>(
&self,
changes: Vec<C>,
)
pub async fn notify_change<C: ChangeNotification<Entity = E, Event = Ev> + Clone>( &self, changes: Vec<C>, )
Notify subscriptions about an entity change
Sourcepub fn system_reset(&self)
pub fn system_reset(&self)
Notify all subscriptions that their entities have been removed but do not remove the subscriptions
Source§impl Reactor<Entity, Attested<Event>>
impl Reactor<Entity, Attested<Event>>
Sourcepub async fn upsert_query<SE, PA>(
&self,
subscription_id: ReactorSubscriptionId,
query_id: QueryId,
collection_id: CollectionId,
selection: Selection,
node: &Node<SE, PA>,
cdata: &PA::ContextData,
version: u32,
) -> Result<Vec<Entity>>
pub async fn upsert_query<SE, PA>( &self, subscription_id: ReactorSubscriptionId, query_id: QueryId, collection_id: CollectionId, selection: Selection, node: &Node<SE, PA>, cdata: &PA::ContextData, version: u32, ) -> Result<Vec<Entity>>
Add or update a query for remote subscriptions (server-side) This method is idempotent - it works whether the query exists or not Constructs gap_fetcher internally using the provided Node and ContextData Returns all entities that currently match the selection (for delta generation)
Trait Implementations§
Source§impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Clone for Reactor<E, Ev>
impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Clone for Reactor<E, Ev>
Source§impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Debug for Reactor<E, Ev>
impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Debug for Reactor<E, Ev>
Auto Trait Implementations§
impl<E, Ev> Freeze for Reactor<E, Ev>
impl<E = Entity, Ev = Attested<Event>> !RefUnwindSafe for Reactor<E, Ev>
impl<E, Ev> Send for Reactor<E, Ev>
impl<E, Ev> Sync for Reactor<E, Ev>
impl<E, Ev> Unpin for Reactor<E, Ev>
impl<E = Entity, Ev = Attested<Event>> !UnwindSafe for Reactor<E, Ev>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more