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

feat: no auto initialization #48

Open
sno2 opened this issue Jan 27, 2022 · 1 comment
Open

feat: no auto initialization #48

sno2 opened this issue Jan 27, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@sno2
Copy link
Contributor

sno2 commented Jan 27, 2022

Hello, it would be nice if instead of eagerly loading the binary library synchronously deno_bindgen would export a function called something like load which would be a function that does Deno.dlopen and attaches all of the helper functions to an object that is returned. Therefore, people could instantiate multiple instances of their library in cases where there is different state that they want instead of having to write multiple awkward dynamic imports. Also, it would help when enabling testing and benchmarking in sub libraries that use deno bindgen to not always need to wait for the synchronous Deno.dlopen call to finish at the start of each run when it may not be needed.

@sno2
Copy link
Contributor Author

sno2 commented Jan 27, 2022

Maybe even export a function named attach which takes in a Deno.DynamicLibrary<T> and then creates the object with the methods generated from the bindgen and returns it. Then, we could still export a load function but make it simply consist of the following:

export function load() {
  const lib = Deno.dlopen("PATH_FROM_BINDGEN", GLOBAL_SYMBOLS);
  return attach(lib); // all of the associated bindings from the bindgen
}

@littledivy littledivy added the enhancement New feature or request label Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants