Skip to content

Commit

Permalink
Introduce explicit internal datastructures modeling dom state (yewsta…
Browse files Browse the repository at this point in the history
…ck#2330)

* detach destructures now

* add failing keyed-list issue

* crude port to the new bundle infrastructure

* port over the infrastructure

the new bcomp is especially nice and lost a few unwraps owed to not having
to reserve space for a scope before rendering.
Note also that bsuspense has been slimmed a bit, storing the suspended flag
implicitly in the state.
some naming is not perfect yet and has to be adjusted still.

* mass rename: apply -> reconcile

* get rid of move_before in favor of shift

* generate id directly when creating a new scope

* bundle for text nodes

* work on naming: ancestor -> bundle

* slightly optimize list reconciler, add doccomments

* address review

* add internal documentation

* address review comments

rename fields in bsuspense
convert to gloo::events

* move even more stuff into dom_bundle to scope exports

- app_handle and layout_tests are now in there
- items are publically re-exported in crate::dom_bundle
- dom_bundle itself is private
- btag and bcomp get their own submodules
- bcomp now contains the lifecycle and scope impls

* move replace into Reconcilable

* move lifecycle and scope back into html as per review

* move back Value and InputFields into html

* actually only type-check format args in production

* fix documentation link

* move btag_impl up into containing module

* shift comps immediately

shifting the rendered Nodes does not tie into the lifecycle,
as such it can happen immediately

* use list-bundle in tag-bundle

* fix cargo make tests

* improve 05_swap benchmark

* fix a blunder where I swapped operands

* fix naming of BNode variants
  • Loading branch information
WorldSEnder authored Mar 6, 2022
1 parent 221b4df commit 78d4204
Show file tree
Hide file tree
Showing 32 changed files with 5,604 additions and 4,946 deletions.
2 changes: 1 addition & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ dependencies = ["test"]
[tasks.test]
private = true
command = "cargo"
args = ["test", "--all-targets", "--workspace", "--exclude", "website-test"]
args = ["test", "--all-targets"]

[tasks.doc-test-flow]
private = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
//! This module contains the `App` struct, which is used to bootstrap
//! a component in an isolated scope.
//! [AppHandle] contains the state Yew keeps to bootstrap a component in an isolated scope.

use std::ops::Deref;

use crate::html::{BaseComponent, NodeRef, Scope, Scoped};
use std::rc::Rc;
use super::{ComponentRenderState, Scoped};
use crate::html::{BaseComponent, Scope};
use crate::NodeRef;
use std::{ops::Deref, rc::Rc};
use web_sys::Element;

/// An instance of an application.
#[derive(Debug)]
pub struct AppHandle<COMP: BaseComponent> {
/// `Scope` holder
pub(crate) scope: Scope<COMP>,
scope: Scope<COMP>,
}

impl<COMP> AppHandle<COMP>
Expand All @@ -27,14 +26,17 @@ where
let app = Self {
scope: Scope::new(None),
};
let node_ref = NodeRef::default();
let initial_render_state =
ComponentRenderState::new(element, NodeRef::default(), &node_ref);
app.scope
.mount_in_place(element, NodeRef::default(), NodeRef::default(), props);
.mount_in_place(initial_render_state, node_ref, props);

app
}

/// Schedule the app for destruction
pub fn destroy(mut self) {
pub fn destroy(self) {
self.scope.destroy(false)
}
}
Expand Down
Loading

0 comments on commit 78d4204

Please sign in to comment.