pub struct LiveView<T> { /* private fields */ }Expand description
A query’s rows, the row of a one() query, or the value of an
aggregate, read as its Rust type and kept current, from
Zero::live (LiveQuery in the Swift client,
useQuery in zero-react).
Each update of the view is read into the value, reading only the rows whose entries changed. When the client replaces itself, the view moves to the new client, and the live view with it. Dropping it removes its listeners and destroys the view; the server keeps syncing the query for its TTL.
Implementations§
Source§impl<T: 'static> LiveView<T>
impl<T: 'static> LiveView<T>
Sourcepub fn value(&self) -> Rc<T>
pub fn value(&self) -> Rc<T>
The value last read. Holding it past the next update makes that update read every row again rather than only those that changed.
Sourcepub fn result_type(&self) -> ResultType
pub fn result_type(&self) -> ResultType
Whether the server has confirmed the rows on this connection
(Complete) or an earlier one (Cached), or not yet (Unknown), or
the query failed (Error).
Sourcepub fn error(&self) -> Option<LiveError>
pub fn error(&self) -> Option<LiveError>
Why the server could not run the query, or why the rows could not be
read as T, which keeps the value last read.
Sourcepub fn view(&self) -> &MaterializedView
pub fn view(&self) -> &MaterializedView
The view the value is read from.
Sourcepub fn update_ttl(&self, ttl: &Ttl)
pub fn update_ttl(&self, ttl: &Ttl)
Raises the query’s TTL; a lower one is ignored.
Sourcepub fn add_listener(
&self,
listener: impl Fn(&T, ResultType) + 'static,
) -> Box<dyn Fn()>
pub fn add_listener( &self, listener: impl Fn(&T, ResultType) + 'static, ) -> Box<dyn Fn()>
Calls listener with the value and result type now, and after every
update of the view, once the value is read. After a read that
failed, it gets the value kept, and error says
why. Returns the function that removes it.