DefaultView now lists localstorage keys
This commit is contained in:
parent
ea1c1b9408
commit
6309c90f34
|
@ -1,9 +1,29 @@
|
|||
use sycamore::prelude::*;
|
||||
|
||||
use crate::local_storage;
|
||||
|
||||
#[component(DefaultView<G>)]
|
||||
pub fn default_view() -> Template<G> {
|
||||
let templates = Template::new_fragment({
|
||||
let mut new_vec: Vec<Template<G>> = Vec::new();
|
||||
|
||||
let keys = local_storage::list_local_storage_keys().to_vec();
|
||||
|
||||
for val in keys {
|
||||
if val.is_string() {
|
||||
if let Some(res) = val.as_string() {
|
||||
new_vec.push(template! { li { (res) } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new_vec
|
||||
});
|
||||
|
||||
template! {
|
||||
p { "Hello, world!" }
|
||||
ul {
|
||||
(templates)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ mod local_storage;
|
|||
|
||||
use sycamore::prelude::*;
|
||||
|
||||
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! log {
|
||||
($($t:tt)*) => (console::log_raw(&format_args!($($t)*).to_string()))
|
||||
}
|
||||
|
@ -15,24 +15,6 @@ pub enum AppMode {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
#[allow(unused_variables)] // Allow because localStorage might be empty
|
||||
let keys = {
|
||||
let mut new_vec: Vec<String> = Vec::new();
|
||||
|
||||
let keys_raw = local_storage::list_local_storage_keys().to_vec();
|
||||
|
||||
for val in keys_raw {
|
||||
if val.is_string() {
|
||||
if let Some(res) = val.as_string() {
|
||||
log!("{}", res);
|
||||
new_vec.push(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new_vec
|
||||
};
|
||||
|
||||
let mode = Signal::new(AppMode::Default);
|
||||
|
||||
sycamore::render(|| template! {
|
||||
|
|
Loading…
Reference in a new issue