Struct sauron::prelude::dom::Program

source ·
pub struct Program<APP>
where APP: Application,
{ pub root_node: Rc<RefCell<Option<DomNode>>>, /* private fields */ }
Expand description

Program handle the lifecycle of the APP

Fields§

§root_node: Rc<RefCell<Option<DomNode>>>

the first element of the app view, where the patch is generated is relative to

Implementations§

source§

impl<APP> Program<APP>
where APP: Application + 'static,

source

pub fn create_dom_node(&self, node: &Node<<APP as Application>::MSG>) -> DomNode

Create a dom node

source§

impl<APP> Program<APP>
where APP: Application,

This impl block contains no items.

A node along with all of the closures that were created for that node’s events and all of it’s child node’s events.

source§

impl<APP> Program<APP>
where APP: Application + 'static,

source

pub fn convert_patch( &self, nodes_lookup: &IndexMap<TreePath, (DomNode, DomNode)>, target_element: &DomNode, target_parent: &DomNode, patch: &Patch<'_, <APP as Application>::MSG> ) -> DomPatch

convert a virtual DOM Patch into a created DOM node Patch

source§

impl<APP> Program<APP>
where APP: Application,

source

pub fn downgrade(&self) -> WeakProgram<APP>

source§

impl<APP> Program<APP>
where APP: Application,

source

pub fn app(&self) -> Ref<'_, APP>

get a reference to the APP

source

pub fn app_mut(&self) -> RefMut<'_, APP>

get a mutable reference to the APP

source§

impl<APP> Program<APP>
where APP: Application,

source

pub fn new(app: APP) -> Program<APP>

Create an Rc wrapped instance of program, initializing DomUpdater with the initial view and root node, but doesn’t mount it yet.

source

pub fn from_rc_app(app: Rc<RefCell<APP>>) -> Program<APP>

create a program from Rc<RefCell>

source

pub fn append_to_mount( app: APP, mount_node: &Node ) -> ManuallyDrop<Program<APP>>

Instantiage an app and append the view to the root_node

§Example
struct App{}
let mount = document().query_selector("#app").ok().flatten().unwrap();
Program::append_to_mount(App{}, &mount);
source

pub fn replace_mount(app: APP, mount_node: &Node) -> ManuallyDrop<Program<APP>>

Creates an Rc wrapped instance of Program and replace the root_node with the app view

§Example
struct App{}
let mount = document().query_selector(".container").ok().flatten().unwrap();
Program::replace_mount(App{}, &mount);
source

pub fn clear_append_to_mount( app: APP, mount_node: &Node ) -> ManuallyDrop<Program<APP>>

clear the existing children of the mount before mounting the app

source

pub fn clear_mount(app: APP, mount_node: &Node) -> ManuallyDrop<Program<APP>>

clear the existing children of the mount before mounting the app

source

pub fn clear_mount_to_body(app: APP) -> ManuallyDrop<Program<APP>>

clear the existing children of the document body before mounting the app

source

pub fn mount_to_body(app: APP) -> ManuallyDrop<Program<APP>>

Instantiate the app and then append it to the document body

§Example
struct App{}
Program::mount_to_body(App{});
source

pub fn pre_mount(&mut self)

executed right before the app is mounted to the dom

source

pub fn mount(&mut self, mount_node: &Node, mount_procedure: MountProcedure)

each element and it’s descendant in the vdom is created into an actual DOM node.

source

pub fn update_dom(&mut self) -> Result<(), JsValue>

execute DOM changes in order to reflect the APP’s view into the browser representation

source

pub fn queue_dom_patches( &mut self, dom_patches: Vec<DomPatch> ) -> Result<(), JsValue>

patch the DOM to reflect the App’s view

Note: This is in another function so as to allow tests to use this shared code

source

pub fn inject_style_to_mount(&mut self, style: &str)

inject style element to the mount node

source

pub fn dispatch_multiple( &mut self, msgs: impl IntoIterator<Item = <APP as Application>::MSG> )

dispatch multiple MSG

source

pub fn dispatch(&mut self, msg: <APP as Application>::MSG)

dispatch a single msg

source§

impl<APP> Program<APP>
where APP: Application,

source

pub fn update_dom_with_vdom( &mut self, new_vdom: Node<<APP as Application>::MSG> ) -> Result<usize, JsValue>

patch the DOM to reflect the App’s view

Note: This is in another function so as to allow tests to use this shared code

Trait Implementations§

source§

impl<APP> Clone for Program<APP>
where APP: Application,

source§

fn clone(&self) -> Program<APP>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<APP> Freeze for Program<APP>

§

impl<APP> !RefUnwindSafe for Program<APP>

§

impl<APP> !Send for Program<APP>

§

impl<APP> !Sync for Program<APP>

§

impl<APP> Unpin for Program<APP>

§

impl<APP> !UnwindSafe for Program<APP>

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.