@blockquote-web-components/blockquote-base-meta
v1.5.36
Published
A modern architecture for building composable and reusable Web Components
Maintainers
Readme
BlockquoteBaseMeta is a generic class for sharing information across the DOM tree, inspired by Polymer's iron-meta.
It employs the monostate pattern to allow any instance to access the shared information.
The class instances hold the actual data. They must be created before attempting to access them.
BlockquoteBaseMeta uses a Map to store the data. Unlike an Object, a Map allows keys of any type.
Demo
Usage
import { BlockquoteBaseMeta } from '@blockquote-web-components/blockquote-base-meta';
const myDefault = new BlockquoteBaseMeta({
key: 'basic',
value: 'foo/bar',
});
console.log(myDefault.byKey('basic')); // foo/barValue Getter - String
import { BlockquoteBaseMeta } from '@blockquote-web-components/blockquote-base-meta';
const myDefault = new BlockquoteBaseMeta({
key: 'basic',
value: 'foo/bar',
});
console.log(myDefault.value); // foo/barList Getter - Array
The list getter returns an array of all values stored in the BlockquoteBaseMeta instance.
import { BlockquoteBaseMeta } from '@blockquote-web-components/blockquote-base-meta';
const myDefault = new BlockquoteBaseMeta({
type: 'three',
key: 'basic',
value: 'foo/bar',
});
console.log(myDefault.list); // ['foo/bar']ObjectList Getter - Object
import { BlockquoteBaseMeta } from '@blockquote-web-components/blockquote-base-meta';
const myDefault = new BlockquoteBaseMeta({
type: 'one',
key: 'basic',
value: 'foo/bar',
});
console.log(myDefault.objectList); // {basic: 'foo/bar'}MapList Getter - Map
import { BlockquoteBaseMeta } from '@blockquote-web-components/blockquote-base-meta';
const keyInfo = { id: 'dsfaskj0' };
const myDefault = new BlockquoteBaseMeta({
type: 'two',
key: keyInfo,
value: 'foo/bar',
});
console.log(myDefault.mapList); // Map(1) { { id: 'dsfaskj0' } => 'foo/bar' }src/BlockquoteBaseMeta.ts:
class: BlockquoteBaseMeta
Static Fields
| Name | Privacy | Type | Default | Description | Inherited From |
| ------- | ------- | ------------------------------------- | ------- | ----------- | -------------- |
| types | | Map<unknown, Map<unknown, unknown>> | | | |
| uuid | | string | | | |
Fields
| Name | Privacy | Type | Default | Description | Inherited From |
| ------------ | ------- | ------------------------- | ------- | --------------------------------------------------------------- | -------------- |
| type | | unknown | type | Type of Meta | |
| key | | unknown | key | Key for Meta | |
| value | | unknown | | Sets value to instance type and key | |
| list | | unknown[] | | Returns a list (Array) of the values for that instance `type` | |
| mapList | | Map<unknown, unknown> | | Returns a list (Map) for that instance `type` | |
| objectList | | Record<string, unknown> | | Returns a list (Object) for that instance `type` | |
Methods
| Name | Privacy | Description | Parameters | Return | Inherited From |
| ------- | ------- | ---------------------------------------------------------------- | -------------- | --------- | -------------- |
| byKey | | Returns the value of the provided key for that instance `type` | key: unknown | unknown | |
Fields
| Name | Privacy | Type | Default | Description | Inherited From |
| ------- | ------- | --------- | ------- | ----------- | -------------- |
| __key | private | unknown | | | |
Exports
| Kind | Name | Declaration | Module | Package |
| ---- | -------------------- | ------------------ | ------------------------- | ------- |
| js | BlockquoteBaseMeta | BlockquoteBaseMeta | src/BlockquoteBaseMeta.ts | |
src/index.ts:
Exports
| Kind | Name | Declaration | Module | Package |
| ---- | -------------------- | ------------------ | ----------------------- | ------- |
| js | BlockquoteBaseMeta | BlockquoteBaseMeta | ./BlockquoteBaseMeta.js | |
