Skip to content

Commit

Permalink
Publish v0.10.0-alpha.1
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz committed Jan 8, 2024
1 parent 22c7ee2 commit 0030d5e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "viewbuilder"
version = "0.9.4"
version = "0.10.0-alpha.1"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Cross-platform UI framework"
Expand Down
5 changes: 5 additions & 0 deletions src/view/lazy.rs
Expand Up @@ -26,18 +26,23 @@ where
type Element = (u64, V::Element);

fn build(&mut self, cx: &mut crate::Context<M>, tree: &mut T) -> Self::Element {
#[cfg(feature = "tracing")]
let span = tracing::trace_span!("View::Build", view = "Lazy");
#[cfg(feature = "tracing")]
let _g = span.enter();

let element = self.view.build(cx, tree);
(self.hash, element)
}

fn rebuild(&mut self, cx: &mut crate::Context<M>, tree: &mut T, element: &mut Self::Element) {
#[cfg(feature = "tracing")]
let span = tracing::trace_span!("View::Rebuild", view = "Lazy");
#[cfg(feature = "tracing")]
let _g = span.enter();

if self.hash != element.0 {
#[cfg(feature = "tracing")]
tracing::trace!(name: "Hash change", new = self.hash, old = element.0);

element.0 = self.hash;
Expand Down
4 changes: 4 additions & 0 deletions src/view/mod.rs
Expand Up @@ -66,14 +66,18 @@ macro_rules! impl_viewbuilder_for_tuple {
type Element = ($($t::Element),*);

fn build(&mut self, cx: &mut Context<M>, tree: &mut T) -> Self::Element {
#[cfg(feature = "tracing")]
let span = tracing::trace_span!("View::Build", view = stringify!(($($t),*)));
#[cfg(feature = "tracing")]
let _g = span.enter();

($(self.$idx.build(cx, tree)),*)
}

fn rebuild(&mut self, cx: &mut Context<M>, tree: &mut T, element: &mut Self::Element) {
#[cfg(feature = "tracing")]
let span = tracing::trace_span!("View::Rebuild", view = stringify!(($($t),*)));
#[cfg(feature = "tracing")]
let _g = span.enter();

$(self.$idx.rebuild(cx, tree, &mut element.$idx));*
Expand Down
4 changes: 4 additions & 0 deletions src/view/once.rs
Expand Up @@ -18,14 +18,18 @@ where
type Element = V::Element;

fn build(&mut self, cx: &mut Context<M>, tree: &mut T) -> Self::Element {
#[cfg(feature = "tracing")]
let span = tracing::trace_span!("View::Build", view = "Once");
#[cfg(feature = "tracing")]
let _g = span.enter();

self.view.build(cx, tree)
}

fn rebuild(&mut self, _cx: &mut Context<M>, _tree: &mut T, _element: &mut Self::Element) {
#[cfg(feature = "tracing")]
let span = tracing::trace_span!("View::Rebuild", view = "Once");
#[cfg(feature = "tracing")]
let _g = span.enter();
}
}
1 change: 0 additions & 1 deletion src/web/html.rs
@@ -1,7 +1,6 @@
use super::{HtmlAttributes, Web};
use crate::{Context, View};
use std::{fmt, marker::PhantomData, mem};
use tracing::{event, span, Level};
use web_sys::{
wasm_bindgen::{closure::Closure, JsCast},
Event,
Expand Down
7 changes: 7 additions & 0 deletions src/web/mod.rs
Expand Up @@ -65,7 +65,9 @@ impl<M> View<Web, M> for &'static str {
}

fn rebuild(&mut self, _cx: &mut Context<M>, _tree: &mut Web, element: &mut Self::Element) {
#[cfg(feature = "tracing")]
let span = tracing::trace_span!("View::Rebuild", view = "&'static str",);
#[cfg(feature = "tracing")]
let _g = span.enter();

if *self != element.0 {
Expand All @@ -79,7 +81,9 @@ impl<M> View<Web, M> for String {
type Element = (Self, Text);

fn build(&mut self, _cx: &mut Context<M>, tree: &mut Web) -> Self::Element {
#[cfg(feature = "tracing")]
let span = tracing::trace_span!("View::Build", view = "String");
#[cfg(feature = "tracing")]
let _g = span.enter();

let text = tree.document.create_text_node(self);
Expand All @@ -88,10 +92,13 @@ impl<M> View<Web, M> for String {
}

fn rebuild(&mut self, _cx: &mut Context<M>, _tree: &mut Web, element: &mut Self::Element) {
#[cfg(feature = "tracing")]
let span = tracing::trace_span!("View::Rebuild", view = "String");
#[cfg(feature = "tracing")]
let _g = span.enter();

if *self != element.0 {
#[cfg(feature = "tracing")]
tracing::event!(name: "Text change", tracing::Level::TRACE, new = &*self, old = element.0);

element.0 = self.clone();
Expand Down

0 comments on commit 0030d5e

Please sign in to comment.