Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idb_sys: expose the Database from the VersionChangeEvent #15

Closed
Ekleog opened this issue Jan 12, 2024 · 2 comments
Closed

idb_sys: expose the Database from the VersionChangeEvent #15

Ekleog opened this issue Jan 12, 2024 · 2 comments

Comments

@Ekleog
Copy link

Ekleog commented Jan 12, 2024

Hey! Considering #7, I'm trying to use idb-sys for my database handling.

I'm just curious, is there any reason why this code is in idb, and not exposed straight from the VersionChangeEvent of idb-sys?

idb/idb/src/database.rs

Lines 129 to 132 in 4576249

fn get_database_from_event(event: Event) -> Result<Database, Error> {
let target = event.target().ok_or(Error::EventTargetNotFound)?;
Database::try_from(target).map_err(Into::into)
}

Anyway, it looks like idb-sys will be a great way for me to have both the reliability I'm looking for, but also some relative ease-of-use compared to web-sys and its untyped API. So, thank you! :D

@Ekleog
Copy link
Author

Ekleog commented Jan 12, 2024

Incidentally, it'd be great if the on_success / on_error callbacks could return an idb_sys::Event type, that'd similarly provide for easy access to the underlying database :)

@devashishdxt
Copy link
Owner

Fixed in #19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants