Lazy Component generators have no need for capture semantics, so... we can make these simpler, behind the scenes.

This commit is contained in:
Ryan McGrath 2019-05-25 03:07:56 -07:00
parent 732f88dec0
commit 4e822fa383
No known key found for this signature in database
GPG key ID: 811674B62B666830
2 changed files with 6 additions and 2 deletions

View file

@ -40,7 +40,11 @@ pub enum RSX {
impl RSX {
/// Shorthand method for creating a new `RSX::VirtualNode` instance. Rarely should you call
/// this yourself; the `rsx! {}` macro handles this for you.
pub fn node<F: Fn() -> Arc<RwLock<Component>> + Send + Sync + 'static>(tag: &'static str, create_fn: F, props: Props) -> RSX {
pub fn node(
tag: &'static str,
create_fn: fn() -> Arc<RwLock<Component>>,
props: Props
) -> RSX {
RSX::VirtualNode(VirtualNode {
tag: tag,
create_component_fn: Arc::new(create_fn),

View file

@ -19,7 +19,7 @@ pub struct VirtualNode {
/// `Component` instances are created on-demand, if the reconciler deems it be so. This
/// is a closure that should return an instance of the correct type.
pub create_component_fn: Arc<Fn() -> Arc<RwLock<Component>> + Send + Sync + 'static>,
pub create_component_fn: Arc<fn() -> Arc<RwLock<Component>>>,
/// A cached component instance, which is transferred between trees. Since `Component`
/// instances are lazily created, this is an `Option`, and defaults to `None`.