Make global registry better accessible externally

This commit is contained in:
Garrett Mills 2022-08-06 15:53:38 -05:00
parent 8774bd8d34
commit 91d76f44b5
2 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@extollo/lib", "name": "@extollo/lib",
"version": "0.13.1", "version": "0.13.2",
"description": "The framework library that lifts up your code.", "description": "The framework library that lifts up your code.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@ -27,6 +27,12 @@ export class GlobalRegistry {
}) })
} }
/** Initialize the global registry in the current sync context. */
public enter(): this {
this.storage.enterWith(new Collection<GlobalRegistrant>())
return this
}
/** /**
* Store the given `value` associated by `key`. * Store the given `value` associated by `key`.
* @param key * @param key
@ -55,7 +61,7 @@ export class GlobalRegistry {
} }
/** Get the globals collection or throw an error if outside async context. */ /** Get the globals collection or throw an error if outside async context. */
protected getCollection(): Collection<GlobalRegistrant> { public getCollection(): Collection<GlobalRegistrant> {
const coll = this.storage.getStore() const coll = this.storage.getStore()
if ( !coll ) { if ( !coll ) {
throw new AccessGlobalRegistryOutsideAsyncLifecycleError() throw new AccessGlobalRegistryOutsideAsyncLifecycleError()