pub struct Cx<'a, B: Backend, T> {
pub world: &'a mut B::World,
/* private fields */
}Fields§
§world: &'a mut B::WorldImplementations§
Source§impl<'a, B: Backend, T: 'static> Cx<'a, B, T>
impl<'a, B: Backend, T: 'static> Cx<'a, B, T>
pub fn new( world: &'a mut B::World, theme: &'a T, mounted: &'a mut Mounted<B, T>, ) -> Self
pub fn theme(&self) -> &'a T
Sourcepub fn effect<P>(
&mut self,
node: B::Node,
value: Prop<B::World, P>,
run: impl FnMut(&mut B::World, B::Node, &P) + Send + Sync + 'static,
)
pub fn effect<P>( &mut self, node: B::Node, value: Prop<B::World, P>, run: impl FnMut(&mut B::World, B::Node, &P) + Send + Sync + 'static, )
Runs run on node with what value holds: once now, and
again whenever a bound value changes to something different,
until the node is unmounted. An unset prop never runs it.
This is how a composite follows a bound value: an element reads its own props, and a composite hands one to this.
Sourcepub fn spawn(&mut self) -> B::Node
pub fn spawn(&mut self) -> B::Node
A new, empty node where a view built now hangs. It is the root of every rule set since the last node was spawned.
Sourcepub fn build(&mut self, view: impl View<B, T>) -> B::Node
pub fn build(&mut self, view: impl View<B, T>) -> B::Node
Builds view where a view built now hangs.
Sourcepub fn under<R>(
&mut self,
parent: B::Node,
build: impl FnOnce(&mut Self) -> R,
) -> R
pub fn under<R>( &mut self, parent: B::Node, build: impl FnOnce(&mut Self) -> R, ) -> R
Runs build with views hanging under parent.
Sourcepub fn at_root<R>(&mut self, build: impl FnOnce(&mut Self) -> R) -> R
pub fn at_root<R>(&mut self, build: impl FnOnce(&mut Self) -> R) -> R
Runs build with views hanging at the root, whatever they
were built under. The rules in force still apply.
Sourcepub fn scope<R>(&mut self, build: impl FnOnce(&mut Self) -> R) -> R
pub fn scope<R>(&mut self, build: impl FnOnce(&mut Self) -> R) -> R
Runs build in a scope of its own: rules it sets end with it.
Sourcepub fn when<C: Condition<B>>(&mut self, set: impl FnOnce(&mut Self))
pub fn when<C: Condition<B>>(&mut self, set: impl FnOnce(&mut Self))
Runs set with the rules it sets holding only while the root
of the view they are set for is in the state C.
On that root they beat its call site, as a state rule does. On a view under it they only fill what that view’s call site left unset, as a set rule does. Either way they beat rules that do not wait on a state.
Sourcepub fn root(&mut self, set: impl FnOnce(&mut Self))
pub fn root(&mut self, set: impl FnOnce(&mut Self))
Runs set with the rules it sets reaching only the root of
the view they are set for: the first node spawned after
them.
Sourcepub fn defaults(&mut self, set: impl FnOnce(&mut Self))
pub fn defaults(&mut self, set: impl FnOnce(&mut Self))
Runs set with the rules it sets weaker than any that are
not, wherever they are: a composite’s defaults, which an
app’s rules should restyle.
Sourcepub fn set<V: Styled>(
&mut self,
rule: impl Fn(V, &T) -> V + Send + Sync + 'static,
)
pub fn set<V: Styled>( &mut self, rule: impl Fn(V, &T) -> V + Send + Sync + 'static, )
Restyles every V built from here to the end of the scope.
A call-site value still beats it.
Sourcepub fn transition(&mut self, motion: Motion)where
T: MotionTokens,
pub fn transition(&mut self, motion: Motion)where
T: MotionTokens,
Makes every element built from here to the end of the scope
travel to new values over the theme’s curve for motion, if
it says how its values blend.
Sourcepub fn transition_over(&mut self, curve: Curve)
pub fn transition_over(&mut self, curve: Curve)
As transition, over curve.
Sourcepub fn set_field<P, X>(&mut self, path: Cursor<P>, value: X)
pub fn set_field<P, X>(&mut self, path: Cursor<P>, value: X)
Sets the field path names to value, on every view path
starts from, from here to the end of the scope. A set rule
like set, but one that says which field it
sets.
The path may reach into a composite’s own parts:
Card::cursor().title().size() sets the size of a card’s
title, and of nothing else.
Sourcepub fn set_field_with<P, X>(
&mut self,
path: Cursor<P>,
read: impl Fn(&T) -> X + Send + Sync + 'static,
)
pub fn set_field_with<P, X>( &mut self, path: Cursor<P>, read: impl Fn(&T) -> X + Send + Sync + 'static, )
As set_field, with the value read from
the theme.
Sourcepub fn trace<V: Styled>(&self, field: FieldId) -> Trace
pub fn trace<V: Styled>(&self, field: FieldId) -> Trace
Which set rules in force for a V could decide field.
Sourcepub fn show<V: Styled>(
&mut self,
rule: impl Fn(V, &T) -> V + Send + Sync + 'static,
)
pub fn show<V: Styled>( &mut self, rule: impl Fn(V, &T) -> V + Send + Sync + 'static, )
Transforms every V built from here to the end of the scope,
after its call site, so unlike a set rule it wins over it.
Sourcepub fn resolve<V: Styled>(&self, view: V) -> V
pub fn resolve<V: Styled>(&self, view: V) -> V
view with the rules in force applied: set rules fill what
its call site left unset, defaults first, then outer
scopes before inner, then show rules transform the result.
Rules waiting on a state are left out: an element puts
them on top while mounted.
Trait Implementations§
Auto Trait Implementations§
impl<'a, B, T> !RefUnwindSafe for Cx<'a, B, T>
impl<'a, B, T> !UnwindSafe for Cx<'a, B, T>
impl<'a, B, T> Freeze for Cx<'a, B, T>
impl<'a, B, T> Send for Cx<'a, B, T>
impl<'a, B, T> Sync for Cx<'a, B, T>
impl<'a, B, T> Unpin for Cx<'a, B, T>
impl<'a, B, T> UnsafeUnpin for Cx<'a, B, T>where
&'a mut <B as Backend>::World: UnsafeUnpin,
&'a T: UnsafeUnpin,
&'a mut Mounted<B, T>: UnsafeUnpin,
Option<<B as Backend>::Node>: UnsafeUnpin,
Vec<ScopeEntry<B>>: UnsafeUnpin,
Marks<B>: UnsafeUnpin,
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<V> ScopedExt for V
impl<V> ScopedExt for V
Source§fn rules<F>(self, rules: F) -> Rules<Self, F>
fn rules<F>(self, rules: F) -> Rules<Self, F>
rules ran first. Rules
marked root reach its root node alone.Source§fn transition(self, motion: Motion) -> Transition<Self>
fn transition(self, motion: Motion) -> Transition<Self>
motion.