diff --git a/Cargo.toml b/Cargo.toml
index e770167ea..b0d9df3f5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -40,7 +40,7 @@ members = [
exclude = ["benchmarks", "examples"]
[workspace.package]
-version = "0.7.0-preview"
+version = "0.7.0-preview2"
rust-version = "1.75"
[workspace.dependencies]
@@ -49,23 +49,23 @@ any_spawner = { path = "./any_spawner/", version = "0.1" }
const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1" }
either_of = { path = "./either_of/", version = "0.1" }
hydration_context = { path = "./hydration_context", version = "0.1" }
-leptos = { path = "./leptos", version = "0.7.0-preview" }
-leptos_config = { path = "./leptos_config", version = "0.7.0-preview" }
-leptos_dom = { path = "./leptos_dom", version = "0.7.0-preview" }
-leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.0-preview" }
-leptos_integration_utils = { path = "./integrations/utils", version = "0.7.0-preview" }
-leptos_macro = { path = "./leptos_macro", version = "0.7.0-preview" }
-leptos_reactive = { path = "./leptos_reactive", version = "0.7.0-preview" }
-leptos_router = { path = "./router", version = "0.7.0-preview" }
-leptos_server = { path = "./leptos_server", version = "0.7.0-preview" }
-leptos_meta = { path = "./meta", version = "0.7.0-preview" }
+leptos = { path = "./leptos", version = "0.7.0-preview2" }
+leptos_config = { path = "./leptos_config", version = "0.7.0-preview2" }
+leptos_dom = { path = "./leptos_dom", version = "0.7.0-preview2" }
+leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.0-preview2" }
+leptos_integration_utils = { path = "./integrations/utils", version = "0.7.0-preview2" }
+leptos_macro = { path = "./leptos_macro", version = "0.7.0-preview2" }
+leptos_reactive = { path = "./leptos_reactive", version = "0.7.0-preview2" }
+leptos_router = { path = "./router", version = "0.7.0-preview2" }
+leptos_server = { path = "./leptos_server", version = "0.7.0-preview2" }
+leptos_meta = { path = "./meta", version = "0.7.0-preview2" }
next_tuple = { path = "./next_tuple", version = "0.1.0-preview" }
oco_ref = { path = "./oco", version = "0.2" }
or_poisoned = { path = "./or_poisoned", version = "0.1" }
reactive_graph = { path = "./reactive_graph", version = "0.1.0-preview" }
-server_fn = { path = "./server_fn", version = "0.7.0-preview" }
-server_fn_macro = { path = "./server_fn_macro", version = "0.7.0-preview" }
-server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.0-preview" }
+server_fn = { path = "./server_fn", version = "0.7.0-preview2" }
+server_fn_macro = { path = "./server_fn_macro", version = "0.7.0-preview2" }
+server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.0-preview2" }
tachys = { path = "./tachys", version = "0.1.0-preview" }
[profile.release]
diff --git a/examples/counter/src/lib.rs b/examples/counter/src/lib.rs
index 2ac97191a..9136bba9e 100644
--- a/examples/counter/src/lib.rs
+++ b/examples/counter/src/lib.rs
@@ -1,4 +1,4 @@
-use leptos::{component, create_signal, prelude::*, view, IntoView};
+use leptos::prelude::*;
/// A simple counter component.
///
@@ -10,7 +10,7 @@ pub fn SimpleCounter(
/// The change that should be applied each time the button is clicked.
step: i32,
) -> impl IntoView {
- let (value, set_value) = create_signal(initial_value);
+ let (value, set_value) = signal(initial_value);
view! {
diff --git a/examples/counter/src/main.rs b/examples/counter/src/main.rs
index 20f7a40d9..6cdabd06c 100644
--- a/examples/counter/src/main.rs
+++ b/examples/counter/src/main.rs
@@ -1,15 +1,10 @@
use counter::SimpleCounter;
-use leptos::*;
+use leptos::prelude::*;
pub fn main() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
mount_to_body(|| {
- view! {
-
- }
+ view! {
}
})
}
diff --git a/examples/counters/src/lib.rs b/examples/counters/src/lib.rs
index 08f1dc1e1..be1fc8d26 100644
--- a/examples/counters/src/lib.rs
+++ b/examples/counters/src/lib.rs
@@ -1,14 +1,5 @@
-use leptos::{
- component,
- prelude::*,
- reactive_graph::{
- owner::{provide_context, use_context},
- signal::{
- create_signal, ArcRwSignal, ReadSignal, RwSignal, WriteSignal,
- },
- },
- view, For, IntoView,
-};
+use leptos::prelude::signal::*;
+use leptos::prelude::*;
const MANY_COUNTERS: usize = 1000;
@@ -49,26 +40,17 @@ pub fn Counters() -> impl IntoView {
view! {
-
-
-
+
+
+
"Total: "
- {move ||
- counters.get()
- .iter()
- .map(|(_, count)| count.get())
- .sum::()
- .to_string()
- }
- " from "
- {move || counters.get().len().to_string()}
+
+ {move || {
+ counters.get().iter().map(|(_, count)| count.get()).sum::().to_string()
+ }}
+
+ " from " {move || counters.get().len().to_string()}
" counters."
@@ -76,11 +58,10 @@ pub fn Counters() -> impl IntoView {
each=move || counters.get()
key=|counter| counter.0
children=move |(id, value)| {
- view! {
-
- }
+ view! { }
}
/>
+
}
@@ -94,13 +75,20 @@ fn Counter(id: usize, value: ArcRwSignal) -> impl IntoView {
view! {
- ().unwrap_or_default()) }
+ on:input:target=move |ev| {
+ value.set(ev.target().value().parse::().unwrap_or_default())
+ }
/>
+
{value.clone()}
-
+
}
}
diff --git a/examples/counters/src/main.rs b/examples/counters/src/main.rs
index b5ffa7ecf..7bf20cc9d 100644
--- a/examples/counters/src/main.rs
+++ b/examples/counters/src/main.rs
@@ -1,5 +1,5 @@
use counters::Counters;
-use leptos::*;
+use leptos::prelude::*;
fn main() {
_ = console_log::init_with_level(log::Level::Debug);
diff --git a/examples/error_boundary/src/lib.rs b/examples/error_boundary/src/lib.rs
index 3ac031182..40f4d8824 100644
--- a/examples/error_boundary/src/lib.rs
+++ b/examples/error_boundary/src/lib.rs
@@ -1,4 +1,4 @@
-use leptos::{component, prelude::*, signal, view, ErrorBoundary, IntoView};
+use leptos::prelude::*;
#[component]
pub fn App() -> impl IntoView {
@@ -40,8 +40,8 @@ pub fn App() -> impl IntoView {
// because `value` is `Result`,
- "You entered " // it will render the `i32` if it is `Ok`,
- // and render nothing and trigger the error boundary
+ // it will render the `i32` if it is `Ok`,
+ "You entered " // and render nothing and trigger the error boundary
// if it is `Err`. It's a signal, so this will dynamically
// update when `value` changes
{value}
diff --git a/examples/error_boundary/src/main.rs b/examples/error_boundary/src/main.rs
index 12c51aef9..317459b7b 100644
--- a/examples/error_boundary/src/main.rs
+++ b/examples/error_boundary/src/main.rs
@@ -1,12 +1,8 @@
use error_boundary::*;
-use leptos::*;
+use leptos::prelude::*;
pub fn main() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
- mount_to_body(|| {
- view! {
-
- }
- })
+ mount_to_body(App)
}
diff --git a/examples/fetch/src/lib.rs b/examples/fetch/src/lib.rs
index 2b5cc4380..c23243bcc 100644
--- a/examples/fetch/src/lib.rs
+++ b/examples/fetch/src/lib.rs
@@ -1,12 +1,4 @@
-use leptos::{
- error::Result,
- prelude::*,
- reactive_graph::{
- computed::AsyncDerived,
- signal::{signal, ArcRwSignal},
- },
- suspend, view, ErrorBoundary, Errors, IntoView, Transition,
-};
+use leptos::prelude::*;
use serde::{Deserialize, Serialize};
use thiserror::Error;
@@ -55,8 +47,7 @@ pub fn fetch_example() -> impl IntoView {
// 2) we'd need to make sure there was a thread-local spawner set up
let cats = AsyncDerived::new_unsync(move || fetch_cats(cat_count.get()));
- let fallback = move |errors: &ArcRwSignal| {
- let errors = errors.clone();
+ let fallback = move |errors: ArcRwSignal| {
let error_list = move || {
errors.with(|errors| {
errors
@@ -86,16 +77,27 @@ pub fn fetch_example() -> impl IntoView {
set_cat_count.set(val);
}
/>
+
"Loading..."
}>
-
- {suspend!(cats.await.map(|cats| {
- cats.into_iter()
- .map(|s| view! { })
- .collect::>()
- }))}
-
+
+ {move || Suspend(async move {
+ cats.await
+ .map(|cats| {
+ cats.into_iter()
+ .map(|s| {
+ view! {
+ -
+
+
+ }
+ })
+ .collect::>()
+ })
+ })}
+
+
diff --git a/examples/fetch/src/main.rs b/examples/fetch/src/main.rs
index 475f34cf3..9faac968f 100644
--- a/examples/fetch/src/main.rs
+++ b/examples/fetch/src/main.rs
@@ -1,5 +1,5 @@
use fetch::fetch_example;
-use leptos::*;
+use leptos::prelude::*;
pub fn main() {
use tracing_subscriber::fmt;
diff --git a/examples/js-framework-benchmark/src/lib.rs b/examples/js-framework-benchmark/src/lib.rs
index a07087d61..bcd4a2430 100644
--- a/examples/js-framework-benchmark/src/lib.rs
+++ b/examples/js-framework-benchmark/src/lib.rs
@@ -1,4 +1,4 @@
-use leptos::*;
+use leptos::prelude::*;
use rand::prelude::*;
use std::sync::atomic::{AtomicUsize, Ordering};
static ADJECTIVES: &[&str] = &[
@@ -86,13 +86,8 @@ fn Button(
text: &'static str,
) -> impl IntoView {
view! {
-
-
@@ -146,19 +141,20 @@ pub fn App() -> impl IntoView {
let is_selected = create_selector(move || selected.get());
view! {
-
-
"Leptos"
+
+
"Leptos"
+
@@ -167,7 +163,7 @@ pub fn App() -> impl IntoView {
impl IntoView {
}
}
/>
+
-
+
}
}
diff --git a/examples/parent_child/src/lib.rs b/examples/parent_child/src/lib.rs
index 734c9cac9..cf34f5c10 100644
--- a/examples/parent_child/src/lib.rs
+++ b/examples/parent_child/src/lib.rs
@@ -1,13 +1,4 @@
-use leptos::{
- callback::{Callback, UnsyncCallback},
- component,
- prelude::*,
- reactive_graph::{
- owner::{provide_context, use_context},
- signal::{signal, WriteSignal},
- },
- view, IntoView,
-};
+use leptos::prelude::*;
use web_sys::MouseEvent;
// This highlights four different ways that child components can communicate
@@ -56,7 +47,10 @@ pub fn App() -> impl IntoView {
// Button C: use a regular event listener
// setting an event listener on a component like this applies it
// to each of the top-level elements the component returns
-
+ //
+ // TODO sorry
I need to take another crack at `on:` here!
+ //
+ //
// Button D gets its setter from context rather than props
@@ -70,14 +64,7 @@ pub fn ButtonA(
/// Signal that will be toggled when the button is clicked.
setter: WriteSignal
,
) -> impl IntoView {
- view! {
-
-
- "Toggle Red"
-
- }
+ view! { "Toggle Red" }
}
/// Button B receives a closure
@@ -89,13 +76,7 @@ pub fn ButtonB(
where
F: FnMut(MouseEvent) + 'static,
{
- view! {
-
- "Toggle Right"
-
- }
+ view! { "Toggle Right" }
}
use leptos::tachys::view::add_attr::AddAnyAttr;
@@ -104,11 +85,7 @@ use leptos::tachys::view::add_attr::AddAnyAttr;
/// its click. Instead, the parent component adds an event listener.
#[component]
pub fn ButtonC() -> impl IntoView + AddAnyAttr {
- view! {
-
- "Toggle Italics"
-
- }
+ view! { "Toggle Italics" }
}
/// Button D is very similar to Button A, but instead of passing the setter as a prop
@@ -118,10 +95,8 @@ pub fn ButtonD() -> impl IntoView {
let setter = use_context::().unwrap().0;
view! {
-
- "Toggle Small Caps"
-
+ "Toggle Small Caps"
}
}
diff --git a/examples/parent_child/src/main.rs b/examples/parent_child/src/main.rs
index 0c7cd5019..6fe204d0a 100644
--- a/examples/parent_child/src/main.rs
+++ b/examples/parent_child/src/main.rs
@@ -1,8 +1,8 @@
-use leptos::*;
+use leptos::prelude::*;
use parent_child::*;
pub fn main() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
- mount_to_body(|| view! { })
+ mount_to_body(App)
}
diff --git a/examples/router/src/lib.rs b/examples/router/src/lib.rs
index ef980aa26..e60315997 100644
--- a/examples/router/src/lib.rs
+++ b/examples/router/src/lib.rs
@@ -1,20 +1,8 @@
mod api;
use crate::api::*;
-use leptos::{
- component,
- prelude::*,
- reactive_graph::{
- computed::AsyncDerived,
- effect::Effect,
- owner::{provide_context, use_context, Owner},
- signal::ArcRwSignal,
- },
- suspend,
- tachys::either::Either,
- view, IntoView, Params, Suspense, Transition,
-};
-use log::{debug, info};
-use routing::{
+use leptos::either::Either;
+use leptos::prelude::*;
+use leptos_router::{
components::{ParentRoute, Redirect, Route, Router, Routes},
hooks::{use_location, use_navigate, use_params},
link::A,
@@ -22,6 +10,7 @@ use routing::{
params::Params,
MatchNestedRoutes, NestedRoute, Outlet, ParamSegment, StaticSegment,
};
+use log::{debug, info};
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
struct ExampleContext(i32);
@@ -66,7 +55,7 @@ pub fn RouterExample() -> impl IntoView {
#[component]
pub fn ContactRoutes() -> impl MatchNestedRoutes + Clone {
view! {
-
+
@@ -87,17 +76,23 @@ pub fn ContactList() -> impl IntoView {
let location = use_location();
let contacts =
AsyncDerived::new(move || get_contacts(location.search.get()));
- let contacts = suspend!(
+ let contacts = move || {
+ Suspend(async move {
// this data doesn't change frequently so we can use .map().collect() instead of a keyed
contacts.await
.into_iter()
.map(|contact| {
view! {
- {contact.first_name} " " {contact.last_name}
+
+
+ {contact.first_name} " " {contact.last_name}
+
+
}
})
.collect::>()
- );
+ })
+ };
view! {
"Contacts"
@@ -139,16 +134,21 @@ pub fn Contact() -> impl IntoView {
)
});
- let contact_display = suspend!(match contact.await {
- None =>
- Either::Left(view! {
"No contact with this ID was found."
}),
- Some(contact) => Either::Right(view! {
-
- {contact.first_name} " " {contact.last_name}
- {contact.address_1}
{contact.address_2}
-
- }),
- });
+ let contact_display = move || {
+ Suspend(async move {
+ match contact.await {
+ None => Either::Left(
+ view! {
"No contact with this ID was found."
},
+ ),
+ Some(contact) => Either::Right(view! {
+
+ {contact.first_name} " " {contact.last_name}
+ {contact.address_1}
{contact.address_2}
+
+ }),
+ }
+ })
+ };
view! {