A Base Registry

### Type parameters

- #### ItemType: RegistryItem

- #### ItemInputType: RegistryInputItem

### Hierarchy

- Registry
  - BlueBaseModuleRegistry
  - ConfigRegistry

## Index

### Constructors

- constructor

### Properties

- BB
- data
- subscriptions

### Methods

- clear
- createItem
- delete
- entries
- filter
- filterValues
- findOne
- forEach
- generateKey
- get
- getKeyAnyItem
- getValue
- has
- isInputItem
- isInputValue
- isItem
- isValue
- keys
- publish
- register
- registerCollection
- set
- setValue
- size
- subscribe
- unsubscribe
- values

## Constructors

### constructor

- new Registry(BB: BlueBase): Registry

- - Defined in registries/Registry.ts:61

  #### Parameters

  - ##### BB: BlueBase

  #### Returns Registry

## Properties

### Protected BB

BB: BlueBase

- Defined in registries/Registry.ts:63

### Protected data

data: Map<string, ItemType> = new Map()

- Defined in registries/Registry.ts:58

Internal data

### Protected subscriptions

subscriptions: Map<string, Map<string, RegistrySubscriptionFn<ItemType>>> = new Map()

- Defined in registries/Registry.ts:61

List of subscriptions

## Methods

### clear

- clear(): void

- - Defined in registries/Registry.ts:221

  The clear() method removes all elements from a Registry object.

  #### Returns void

### Protected createItem

- createItem(key: string, partial: ItemType | ItemInputType): ItemType

- - Defined in registries/Registry.ts:364

  Convert any input value to an item. This is where you transform inputs and add defualts

  #### Parameters

  - ##### key: string

  - ##### partial: ItemType | ItemInputType

  #### Returns ItemType

### delete

- delete(key: string): boolean

- - Defined in registries/Registry.ts:214

  The delete() method removes the specified element from a Registry object.

  #### Parameters

  - ##### key: string

  #### Returns boolean

### entries

- entries(): IterableIterator<Object>

- - Defined in registries/Registry.ts:230

  The entries() method returns a new Iterator object that contains the [key, value] pairs for each element in the Registry object in insertion order.

  #### Returns IterableIterator<Object>

### filter

- filter(predicate: function): object

- - Defined in registries/Registry.ts:274

  Filter registry items by a predicate function.

  #### Parameters

  - ##### predicate: function

    - - (value: ItemType["value"], key: string, item: ItemType): boolean

      - #### Parameters

        - ##### value: ItemType["value"]

        - ##### key: string

        - ##### item: ItemType

        #### Returns boolean

  #### Returns object

  - ##### [key: string]: ItemType

### filterValues

- filterValues(predicate: function): object

- - Defined in registries/Registry.ts:291

  Filter registry items by a predicate function.

  #### Parameters

  - ##### predicate: function

    - - (value: ItemType["value"], key: string, item: ItemType): boolean

      - #### Parameters

        - ##### value: ItemType["value"]

        - ##### key: string

        - ##### item: ItemType

        #### Returns boolean

  #### Returns object

  - ##### [key: string]: ItemType

### Protected findOne

- findOne(...keys: string[]): undefined | ItemType

- - Defined in registries/Registry.ts:428

  Find one item in a given sequence. Returns the first item found.

  #### Parameters

  - ##### Rest ...keys: string[]

  #### Returns undefined | ItemType

### forEach

- forEach(callbackfn: function, thisArg?: any): void

- - Defined in registries/Registry.ts:263

  The forEach() method executes a provided function once per each key/value pair in the Registry object, in insertion order.

  #### Parameters

  - ##### callbackfn: function

    - - (value: ItemType, key: string, map: Map<string, ItemType>): void

      - #### Parameters

        - ##### value: ItemType

        - ##### key: string

        - ##### map: Map<string, ItemType>

        #### Returns void

  - ##### Optional thisArg: any

  #### Returns void

### Protected generateKey

- generateKey(_item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]): string | undefined

- - Defined in registries/Registry.ts:490

  This function is used to auto generate an item key

  #### Parameters

  - ##### _item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]

  #### Returns string | undefined

### get

- get(...keys: string[]): undefined | ItemType

- - Defined in registries/Registry.ts:71

  The get() method returns a specified registry item.

  #### Parameters

  - ##### Rest ...keys: string[]

  #### Returns undefined | ItemType

### Protected getKeyAnyItem

- getKeyAnyItem(item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]): object
- getKeyAnyItem(key: string, item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]): object

- - Defined in registries/Registry.ts:445

  Used internally by the register method. Since this function as many overloads, resolves final key and value params.

  #### Parameters

  - ##### item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]

  #### Returns object

  - ##### item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]

  - ##### key: string

- - Defined in registries/Registry.ts:448

  #### Parameters

  - ##### key: string

  - ##### item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]

  #### Returns object

  - ##### item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]

  - ##### key: string

### getValue

- getValue(...keys: string[]): ItemType["value"] | undefined

- - Defined in registries/Registry.ts:115

  The getValue() method returns a specified value from a Registry object.

  #### Parameters

  - ##### Rest ...keys: string[]

  #### Returns ItemType["value"] | undefined

### has

- has(key: string): boolean

- - Defined in registries/Registry.ts:206

  The has() method returns a boolean indicating whether an element with the specified key exists or not.

  #### Parameters

  - ##### key: string

  #### Returns boolean

### Protected isInputItem

- isInputItem(item: any): boolean

- - Defined in registries/Registry.ts:405

  Typeguard to check a given object is a input item

  #### Parameters

  - ##### item: any

  #### Returns boolean

### Protected isInputValue

- isInputValue(value: any): boolean

- - Defined in registries/Registry.ts:389

  Typeguard to check a given object is an input value

  #### Parameters

  - ##### value: any

  #### Returns boolean

### Protected isItem

- isItem(item: any): boolean

- - Defined in registries/Registry.ts:397

  Typeguard to check a given object is a registry item

  #### Parameters

  - ##### item: any

  #### Returns boolean

### Protected isValue

- isValue(value: any): boolean

- - Defined in registries/Registry.ts:381

  Typeguard to check a given object is a registry value

  #### Parameters

  - ##### value: any

  #### Returns boolean

### keys

- keys(): IterableIterator<string>

- - Defined in registries/Registry.ts:238

  The keys() method returns a new Iterator object that contains the keys for each element in the Registry object in insertion order.

  #### Returns IterableIterator<string>

### Protected publish

- publish(key: string, item: ItemType): void

- - Defined in registries/Registry.ts:414

  Publishes updates of a config value change to all the subscribers

  #### Parameters

  - ##### key: string

  - ##### item: ItemType

  #### Returns void

### register

- register(item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]): Promise<string>
- register(key: string, item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]): Promise<string>

- - Defined in registries/Registry.ts:152

  Adds an Item or an Item value to the registry.

  #### Parameters

  - ##### item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]

  #### Returns Promise<string>

- - Defined in registries/Registry.ts:155

  #### Parameters

  - ##### key: string

  - ##### item: ItemType | ItemType["value"] | ItemInputType | ItemInputType["value"]

  #### Returns Promise<string>

### registerCollection

- registerCollection(collection?: ItemCollection<ItemInputType>): Promise<void>

- - Defined in registries/Registry.ts:180

  Register a collection of items.

  #### Parameters

  - ##### Default value collection: ItemCollection<ItemInputType> = []

  #### Returns Promise<void>

### set

- set(key: string, item: ItemType | ItemInputType): this

- - Defined in registries/Registry.ts:91

  The set() method adds or updates an element with a specified key and item to the registry.

  #### Parameters

  - ##### key: string

  - ##### item: ItemType | ItemInputType

  #### Returns this

### setValue

- setValue(key: string, value: ItemType["value"] | ItemInputType["value"]): this

- - Defined in registries/Registry.ts:134

  The setValue() method adds or updates the value a registry item with the specified key.

  #### Parameters

  - ##### key: string

  - ##### value: ItemType["value"] | ItemInputType["value"]

  #### Returns this

### size

- size(): number

- - Defined in registries/Registry.ts:253

  Returns the number of items in the Registry.

  #### Returns number

### subscribe

- subscribe(key: string, callback: RegistrySubscriptionFn<ItemType>): string

- - Defined in registries/Registry.ts:312

  Subscribe to a config value update

  #### Parameters

  - ##### key: string

    Config key

  - ##### callback: RegistrySubscriptionFn<ItemType>

    Callback function

  #### Returns string

  Subscription ID

### unsubscribe

- unsubscribe(key: string, subscriptionId: string): void

- - Defined in registries/Registry.ts:337

  Unsubscribe from a config value update

  #### Parameters

  - ##### key: string

    Config key

  - ##### subscriptionId: string

    Subscription ID

  #### Returns void

### values

- values(): IterableIterator<ItemType>

- - Defined in registries/Registry.ts:246

  The values() method returns a new Iterator object that contains the values for each element in the Registry object in insertion order.

  #### Returns IterableIterator<ItemType>

Generated using TypeDoc