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

Explain how LAPIs can use other LAPIs (without monkeypatching interference) #32

Open
domenic opened this issue Jul 31, 2018 · 0 comments

Comments

@domenic
Copy link
Collaborator

domenic commented Jul 31, 2018

This has been in my head for a while but never written down. I should turn this issue into a Markdown document in this repo but let's just record it here for now.

Current back-pocket solution:

// async-local-storage

// "Real" exports:
export class StorageArea { ... };
export const storage = new StorageArea("default");

// Exports meant mainly for use by other LAPIs:
export const StorageArea_prototype_get = StorageArea.prototype.get;
export const StorageArea_prototype_set = StorageArea.prototype.set;
// ... etc ...
// other-lapi-that-needs-storage
import { storage, StorageArea_prototype_get } from "std:async-local-storage";
const Reflect_call = getOriginalStatic("Reflect", "call");

const result = Reflect_call(StorageArea_prototype_get, storage);

An ideal solution would be to make get-originals extensible so that authors could register "their" originals. That would avoid the split between get-originals for platform code, and ugly-manual-exports for LAPIs that want to share with each other.

That's a bit tricky with the current get-originals design, but we should keep an eye on it as get-originals evolves, since the design is nowhere near settled.

@domenic domenic changed the title Explain how LAPIs can use other ways (without monkeypatching interference) Explain how LAPIs can use other LAPIs (without monkeypatching interference) Aug 3, 2018
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

1 participant