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

Use a global GRIDS store #34

Closed
Rennzie opened this issue Nov 17, 2023 · 0 comments · Fixed by #35
Closed

Use a global GRIDS store #34

Rennzie opened this issue Nov 17, 2023 · 0 comments · Fixed by #35
Assignees

Comments

@Rennzie
Copy link
Owner

Rennzie commented Nov 17, 2023

  • To avoid unsafe usage it requires that Geodesy adds Sync + Send to the Grid trait.
  • Remove the GridLoader class in favour of free functions.

Something like this:

static GRIDS: Lazy<Mutex<GridCollection>> =
    Lazy::new(|| Mutex::new(BTreeMap::<String, Arc<dyn Grid>>::new()));

#[wasm_bindgen(js_name = loadGrid)]
// If no data_view then the key is either a URL or an IndexDb key
pub fn load_grid(key: &str, data_view: Option<js::DataView>) -> WasmResult {
   let parse_grid =    //.. Parse and load grid 
   GRIDS.lock().unwrap().add(key, parsed_grid)
}


//... Later in Geo.get_grid()

fn get_grid(&self, key: &str) -> Result<Arc<dyn Grid>>{
   GRIDS.get(key)
}
@Rennzie Rennzie self-assigned this Nov 17, 2023
@Rennzie Rennzie linked a pull request Nov 20, 2023 that will close this issue
@Rennzie Rennzie mentioned this issue Dec 8, 2023
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

Successfully merging a pull request may close this issue.

1 participant