mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
rename from new_serde to new
This commit is contained in:
parent
10230d6d65
commit
ce832cef21
11 changed files with 25 additions and 25 deletions
|
@ -103,7 +103,7 @@ pub fn Counter() -> impl IntoView {
|
|||
let dec = Action::new(|_: &()| adjust_server_count(-1, "decing".into()));
|
||||
let inc = Action::new(|_: &()| adjust_server_count(1, "incing".into()));
|
||||
let clear = Action::new(|_: &()| clear_server_count());
|
||||
let counter = Resource::new_serde(
|
||||
let counter = Resource::new(
|
||||
move || {
|
||||
(
|
||||
dec.version().get(),
|
||||
|
@ -145,7 +145,7 @@ pub fn FormCounter() -> impl IntoView {
|
|||
let adjust = ServerAction::<AdjustServerCount>::new();
|
||||
let clear = ServerAction::<ClearServerCount>::new();
|
||||
|
||||
let counter = Resource::new_serde(
|
||||
let counter = Resource::new(
|
||||
move || (adjust.version().get(), clear.version().get()),
|
||||
|_| {
|
||||
log::debug!("FormCounter running fetcher");
|
||||
|
|
|
@ -32,7 +32,7 @@ pub fn Stories() -> impl IntoView {
|
|||
.get("stories")
|
||||
.unwrap_or_else(|| "top".to_string())
|
||||
};
|
||||
let stories = Resource::new_serde(
|
||||
let stories = Resource::new(
|
||||
move || (page(), story_type()),
|
||||
move |(page, story_type)| async move {
|
||||
let path = format!("{}?page={}", category(&story_type), page);
|
||||
|
|
|
@ -8,7 +8,7 @@ use leptos_router::hooks::use_params_map;
|
|||
#[component]
|
||||
pub fn Story() -> impl IntoView {
|
||||
let params = use_params_map();
|
||||
let story = Resource::new_serde(
|
||||
let story = Resource::new(
|
||||
move || params.read().get("id").unwrap_or_default(),
|
||||
move |id| async move {
|
||||
if id.is_empty() {
|
||||
|
|
|
@ -6,7 +6,7 @@ use leptos_router::hooks::use_params_map;
|
|||
#[component]
|
||||
pub fn User() -> impl IntoView {
|
||||
let params = use_params_map();
|
||||
let user = Resource::new_serde(
|
||||
let user = Resource::new(
|
||||
move || params.read().get("id").unwrap_or_default(),
|
||||
move |id| async move {
|
||||
if id.is_empty() {
|
||||
|
|
|
@ -176,7 +176,7 @@ pub fn WithAnAction() -> impl IntoView {
|
|||
// this resource will hold the total number of rows
|
||||
// passing it action.version() means it will refetch whenever the action resolves successfully
|
||||
let row_count =
|
||||
Resource::new_serde(move || action.version().get(), |_| get_rows());
|
||||
Resource::new(move || action.version().get(), |_| get_rows());
|
||||
|
||||
view! {
|
||||
<h3>Using <code>Action::new</code></h3>
|
||||
|
@ -216,7 +216,7 @@ pub fn WithAnAction() -> impl IntoView {
|
|||
pub fn WithActionForm() -> impl IntoView {
|
||||
let action = ServerAction::<AddRow>::new();
|
||||
let row_count =
|
||||
Resource::new_serde(move || action.version().get(), |_| get_rows());
|
||||
Resource::new(move || action.version().get(), |_| get_rows());
|
||||
|
||||
view! {
|
||||
<h3>Using <code>"<ActionForm/>"</code></h3>
|
||||
|
@ -317,7 +317,7 @@ pub async fn rkyv_example(input: String) -> Result<String, ServerFnError> {
|
|||
pub fn RkyvExample() -> impl IntoView {
|
||||
let input_ref = NodeRef::<Input>::new();
|
||||
let (input, set_input) = signal(String::new());
|
||||
let rkyv_result = Resource::new_serde(move || input.get(), rkyv_example);
|
||||
let rkyv_result = Resource::new(move || input.get(), rkyv_example);
|
||||
|
||||
view! {
|
||||
<h3>Using <code>rkyv</code> encoding</h3>
|
||||
|
|
|
@ -47,7 +47,7 @@ pub fn App() -> impl IntoView {
|
|||
#[component]
|
||||
fn HomePage() -> impl IntoView {
|
||||
// load the posts
|
||||
let posts = Resource::new_serde(|| (), |_| list_post_metadata());
|
||||
let posts = Resource::new(|| (), |_| list_post_metadata());
|
||||
let posts = move || {
|
||||
posts
|
||||
.get()
|
||||
|
@ -55,7 +55,7 @@ fn HomePage() -> impl IntoView {
|
|||
.unwrap_or_default()
|
||||
};
|
||||
|
||||
let posts2 = Resource::new_serde(|| (), |_| list_post_metadata());
|
||||
let posts2 = Resource::new(|| (), |_| list_post_metadata());
|
||||
let posts2 = Resource::new(
|
||||
|| (),
|
||||
move |_| async move { posts2.await.as_ref().map(Vec::len).unwrap_or(0) },
|
||||
|
@ -95,7 +95,7 @@ fn Post() -> impl IntoView {
|
|||
.map_err(|_| PostError::InvalidId)
|
||||
})
|
||||
};
|
||||
let post_resource = Resource::new_serde(id, |id| async move {
|
||||
let post_resource = Resource::new(id, |id| async move {
|
||||
match id {
|
||||
Err(e) => Err(e),
|
||||
Ok(id) => get_post(id)
|
||||
|
|
|
@ -66,7 +66,7 @@ pub fn App() -> impl IntoView {
|
|||
#[component]
|
||||
fn HomePage() -> impl IntoView {
|
||||
// load the posts
|
||||
let posts = Resource::new_serde(|| (), |_| list_post_metadata());
|
||||
let posts = Resource::new(|| (), |_| list_post_metadata());
|
||||
let posts = move || {
|
||||
posts
|
||||
.get()
|
||||
|
@ -74,7 +74,7 @@ fn HomePage() -> impl IntoView {
|
|||
.unwrap_or_default()
|
||||
};
|
||||
|
||||
let posts2 = Resource::new_serde(|| (), |_| list_post_metadata());
|
||||
let posts2 = Resource::new(|| (), |_| list_post_metadata());
|
||||
let posts2 = Resource::new(
|
||||
|| (),
|
||||
move |_| async move { posts2.await.as_ref().map(Vec::len).unwrap_or(0) },
|
||||
|
@ -114,7 +114,7 @@ fn Post() -> impl IntoView {
|
|||
.map_err(|_| PostError::InvalidId)
|
||||
})
|
||||
};
|
||||
let post_resource = Resource::new_serde(id, |id| async move {
|
||||
let post_resource = Resource::new(id, |id| async move {
|
||||
match id {
|
||||
Err(e) => Err(e),
|
||||
Ok(id) => get_post(id)
|
||||
|
|
|
@ -120,8 +120,8 @@ fn SecondaryNav() -> impl IntoView {
|
|||
|
||||
#[component]
|
||||
fn Nested() -> impl IntoView {
|
||||
let one_second = Resource::new_serde(|| WAIT_ONE_SECOND, first_wait_fn);
|
||||
let two_second = Resource::new_serde(|| WAIT_TWO_SECONDS, second_wait_fn);
|
||||
let one_second = Resource::new(|| WAIT_ONE_SECOND, first_wait_fn);
|
||||
let two_second = Resource::new(|| WAIT_TWO_SECONDS, second_wait_fn);
|
||||
let (count, set_count) = signal(0);
|
||||
|
||||
view! {
|
||||
|
@ -149,7 +149,7 @@ fn Nested() -> impl IntoView {
|
|||
|
||||
#[component]
|
||||
fn NestedResourceInside() -> impl IntoView {
|
||||
let one_second = Resource::new_serde(|| WAIT_ONE_SECOND, first_wait_fn);
|
||||
let one_second = Resource::new(|| WAIT_ONE_SECOND, first_wait_fn);
|
||||
let (count, set_count) = signal(0);
|
||||
|
||||
view! {
|
||||
|
@ -157,7 +157,7 @@ fn NestedResourceInside() -> impl IntoView {
|
|||
<Suspense fallback=|| "Loading 1...">
|
||||
{Suspend(async move {
|
||||
_ = one_second.await;
|
||||
let two_second = Resource::new_serde(|| (), move |_| async move {
|
||||
let two_second = Resource::new(|| (), move |_| async move {
|
||||
second_wait_fn(WAIT_TWO_SECONDS).await
|
||||
});
|
||||
view! {
|
||||
|
@ -180,8 +180,8 @@ fn NestedResourceInside() -> impl IntoView {
|
|||
|
||||
#[component]
|
||||
fn Parallel() -> impl IntoView {
|
||||
let one_second = Resource::new_serde(|| WAIT_ONE_SECOND, first_wait_fn);
|
||||
let two_second = Resource::new_serde(|| WAIT_TWO_SECONDS, second_wait_fn);
|
||||
let one_second = Resource::new(|| WAIT_ONE_SECOND, first_wait_fn);
|
||||
let two_second = Resource::new(|| WAIT_TWO_SECONDS, second_wait_fn);
|
||||
let (count, set_count) = signal(0);
|
||||
|
||||
view! {
|
||||
|
@ -212,7 +212,7 @@ fn Parallel() -> impl IntoView {
|
|||
|
||||
#[component]
|
||||
fn Single() -> impl IntoView {
|
||||
let one_second = Resource::new_serde(|| WAIT_ONE_SECOND, first_wait_fn);
|
||||
let one_second = Resource::new(|| WAIT_ONE_SECOND, first_wait_fn);
|
||||
let (count, set_count) = signal(0);
|
||||
|
||||
view! {
|
||||
|
@ -254,7 +254,7 @@ fn InsideComponent() -> impl IntoView {
|
|||
|
||||
#[component]
|
||||
fn InsideComponentChild() -> impl IntoView {
|
||||
let one_second = Resource::new_serde(|| WAIT_ONE_SECOND, first_wait_fn);
|
||||
let one_second = Resource::new(|| WAIT_ONE_SECOND, first_wait_fn);
|
||||
view! {
|
||||
<Suspense fallback=|| "Loading 1...">
|
||||
{move || {
|
||||
|
|
|
@ -101,7 +101,7 @@ pub fn Todos() -> impl IntoView {
|
|||
let delete_todo = ServerAction::<DeleteTodo>::new();
|
||||
|
||||
// list of todos is loaded from the server in reaction to changes
|
||||
let todos = Resource::new_serde(
|
||||
let todos = Resource::new(
|
||||
move || {
|
||||
(
|
||||
delete_todo.version().get(),
|
||||
|
|
|
@ -122,7 +122,7 @@ pub fn Todos() -> impl IntoView {
|
|||
let delete_todo = ServerAction::<DeleteTodo>::new();
|
||||
|
||||
// list of todos is loaded from the server in reaction to changes
|
||||
let todos = Resource::new_serde(
|
||||
let todos = Resource::new(
|
||||
move || {
|
||||
(
|
||||
delete_todo.version().get(),
|
||||
|
|
|
@ -122,7 +122,7 @@ pub fn Todos() -> impl IntoView {
|
|||
let delete_todo = ServerAction::<DeleteTodo>::new();
|
||||
|
||||
// list of todos is loaded from the server in reaction to changes
|
||||
let todos = Resource::new_serde(
|
||||
let todos = Resource::new(
|
||||
move || {
|
||||
(
|
||||
delete_todo.version().get(),
|
||||
|
|
Loading…
Reference in a new issue