diff --git a/examples/router/index.html b/examples/router/index.html
index b5ec4d243..7e3c8d4b2 100644
--- a/examples/router/index.html
+++ b/examples/router/index.html
@@ -2,6 +2,17 @@
+
\ No newline at end of file
diff --git a/examples/router/src/api.rs b/examples/router/src/api.rs
index e91c2c346..def4d77bd 100644
--- a/examples/router/src/api.rs
+++ b/examples/router/src/api.rs
@@ -29,17 +29,29 @@ pub struct Contact {
pub async fn get_contacts(search: String) -> Vec {
// fake an API call with an artificial delay
- delay(Duration::from_millis(100)).await;
- vec![ContactSummary {
- id: 0,
- first_name: "Bill".into(),
- last_name: "Smith".into(),
- }]
+ delay(Duration::from_millis(300)).await;
+ vec![
+ ContactSummary {
+ id: 0,
+ first_name: "Bill".into(),
+ last_name: "Smith".into(),
+ },
+ ContactSummary {
+ id: 1,
+ first_name: "Tim".into(),
+ last_name: "Jones".into(),
+ },
+ ContactSummary {
+ id: 2,
+ first_name: "Sally".into(),
+ last_name: "Stevens".into(),
+ },
+ ]
}
pub async fn get_contact(id: Option) -> Option {
// fake an API call with an artificial delay
- delay(Duration::from_millis(350)).await;
+ delay(Duration::from_millis(500)).await;
match id {
Some(0) => Some(Contact {
id: 0,
@@ -53,6 +65,30 @@ pub async fn get_contact(id: Option) -> Option {
email: "bill@smith.com".into(),
phone: "617-121-1221".into(),
}),
+ Some(1) => Some(Contact {
+ id: 1,
+ first_name: "Tim".into(),
+ last_name: "Jones".into(),
+ address_1: "56 Main Street".into(),
+ address_2: "".into(),
+ city: "Chattanooga".into(),
+ state: "TN".into(),
+ zip: "13371".into(),
+ email: "timjones@lmail.com".into(),
+ phone: "232-123-1337".into(),
+ }),
+ Some(2) => Some(Contact {
+ id: 2,
+ first_name: "Sally".into(),
+ last_name: "Stevens".into(),
+ address_1: "404 E 123rd St".into(),
+ address_2: "Apt 7E".into(),
+ city: "New York".into(),
+ state: "NY".into(),
+ zip: "10082".into(),
+ email: "sally.stevens@wahoo.net".into(),
+ phone: "242-121-3789".into(),
+ }),
_ => None,
}
}
diff --git a/examples/router/src/lib.rs b/examples/router/src/lib.rs
index 96ac7047d..244f273e8 100644
--- a/examples/router/src/lib.rs
+++ b/examples/router/src/lib.rs
@@ -13,105 +13,148 @@ use crate::api::{get_contact, get_contacts};
fn contact_list(
cx: Scope,
- params: ParamsMap,
+ params: Memo,
location: Location,
) -> Resource> {
log::debug!("(contact_list) reloading contact list");
- create_resource(cx, location.search, move |s| get_contacts(s.to_string()))
+ create_resource(cx, location.search, get_contacts)
}
fn contact(
cx: Scope,
- params: ParamsMap,
+ params: Memo,
location: Location,
) -> Resource