@encodable/registry
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "@encodable/registry", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "All-purpose map data structure on steroids.", | ||
@@ -41,3 +41,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "76988b00f9b22c22fbe0ba660b0f4bd4438df7ed" | ||
"gitHead": "03981d54b94928eec00c47bec02930f0d7b62ad6" | ||
} |
@@ -18,31 +18,4 @@ ## @encodable/registry | ||
### Example usage | ||
### Documentation | ||
Create registries | ||
```ts | ||
import { Registry, SyncRegistry, makeSingleton } from '@encodable/registry'; | ||
// local registry (when globalId is not defined) | ||
const registry = new Registry<string>(); | ||
// global registry | ||
const globalRegistry = new Registry({ globalId: 'my-global-key' }); | ||
const singleton = makeSingleton(() => new Registry({ globalId: 'my-global-key' })); | ||
``` | ||
Registering | ||
```ts | ||
// constant value | ||
registry.registerValue('key', 1); | ||
// sync loader | ||
registry.registerLoader('key', () => 1); | ||
// async loader | ||
registry.registerLoader('key', () => Promise.resolve(1)); | ||
``` | ||
* `Registry` can support both constant values and sync/async loaders. | ||
* `SyncRegistry` only support constant values and sync loaders. | ||
[See documentation and more examples here.](https://encodable.vercel.app/encodable-registry) |
45396
21