-
-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Labels
ReleasedThis issue's resolution is now available in a published releaseThis issue's resolution is now available in a published release
Description
Based on https://github.com/leptos-rs/leptos/tree/main/examples/tailwind_csr_trunk
use indexed_db_futures::{
prelude::{IdbObjectStore, IdbTransaction},
request::IdbOpenDbRequestLike,
web_sys::IdbTransactionMode,
IdbDatabase, IdbQuerySource, IdbVersionChangeEvent,
};
use leptos::*;
use wasm_bindgen::JsValue;
use crate::app::navbar::Navbar;
async fn prepare_db() -> String {
println!("prepare db");
let mut db_req = indexed_db_futures::IdbDatabase::open_u32("my_db", 1).unwrap();
db_req.set_on_upgrade_needed(Some(|evt: &IdbVersionChangeEvent| -> Result<(), JsValue> {
// Check if the object store exists; create it if it doesn't
println!("upgrade needed");
if let None = evt.db().object_store_names().find(|n| n == "my_store") {
evt.db().create_object_store("my_store")?;
}
Ok(())
}));
Ok("test".to_string())
}
#[component]
pub fn Settings(cx: Scope) -> impl IntoView {
let settings = create_local_resource(cx, || (), |_| async { prepare_db().await });
view! { cx,
<Navbar></Navbar>
<div class="flex flex-col w-full border-opacity-50">
<div class="grid h-20 card rounded-box place-items-center">
<div class="card w-9/12 bg-secondary-content shadow-xl">
<div class="card-body">
<Await
// `future` provides the `Future` to be resolved
future=|cx| prepare_db()
// the data is bound to whatever variable name you provide
bind:data
>
<p>{data} " example..."</p>
</Await>
</div>
</div>
</div>
}
}
the console prints
tailwind-csr-trunk-b03fafd26d188d41.js:353 panicked at src/app/settings.rs:29:10:
called `Result::unwrap()` on an `Err` value: DomException { obj: Object { obj: JsValue(NotFoundError: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Error: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
at http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41.js:640:33
at handleError (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41.js:285:18)
at imports.wbg.__wbg_transaction_d6f1ef0b34b58a31 (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41.js:638:70)
at web_sys::features::gen_IdbDatabase::IdbDatabase::transaction_with_str_and_mode::h9680dab48f88a29d (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[2074]:0x321e85)
at indexed_db_futures::idb_database::IdbDatabase::transaction_on_one_with_mode::h6d88b6cf300c7fe8 (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[1260]:0x2cd142)
at tailwind_csr_trunk::app::settings::prepare_db::{{closure}}::h6768f907d6776f11 (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[494]:0x2184ae)
at tailwind_csr_trunk::app::settings::Settings::__Settings::{{closure}}::{{closure}}::h137b5fabeaf8260e (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[1226]:0x2c8ad7)
at <core::pin::Pin<P> as core::future::future::Future>::poll::h5f631c18c6c04a0b (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[4431]:0x3ae561)
at leptos_reactive::resource::ResourceState<S,T>::load::{{closure}}::{{closure}}::hf79dd7b6b235cccc (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[164]:0x41b99)
at wasm_bindgen_futures::task::singlethread::Task::run::h9d4a0df6390fda94 (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[1257]:0x2ccbca)) } }
Stack:
Error
at imports.wbg.__wbg_new_abda76e883ba8a5f (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41.js:356:17)
at console_error_panic_hook::Error::new::hf9c38ed484c370cc (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[7904]:0x40051c)
at console_error_panic_hook::hook_impl::hf60de235cbe0d0f8 (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[1679]:0x2fd107)
at console_error_panic_hook::hook::h56198eb557ac7d98 (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[8471]:0x4083af)
at core::ops::function::Fn::call::ha69410e5d033974e (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[7598]:0x3fb91b)
at std::panicking::rust_panic_with_hook::he756764f61c69795 (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[3570]:0x387195)
at std::panicking::begin_panic_handler::{{closure}}::hc32c236557ee2684 (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[4445]:0x3aee18)
at std::sys_common::backtrace::__rust_end_short_backtrace::hb038a7c53aa47b5e (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[10033]:0x417335)
at rust_begin_unwind (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[6207]:0x3e1634)
at core::panicking::panic_fmt::h4f7b0621cfc33d8f (http://127.0.0.1:8080/tailwind-csr-trunk-b03fafd26d188d41_bg.wasm:wasm-function[8347]:0x406a4e)
Metadata
Metadata
Assignees
Labels
ReleasedThis issue's resolution is now available in a published releaseThis issue's resolution is now available in a published release