Skip to content

DictionaryTemplate

Type class

A version of a Dictionary that has a "template".

A template is an instance of an object, that can be used to create new elements in the list without actually needing to create instances for those.

When new element is created in the list, e.g. by calling its create() method, an exact copy of the element is created (including properties and other attributes), inserted into the list and returned.

Sources

DictionaryTemplate can be used (imported) via one of the following packages.

/**
* Import from: "core.ts"
* Use like: am4core.DictionaryTemplate
*/
import * as am4core from "@amcharts/amcharts4/core";

Inheritance

DictionaryTemplate extends Dictionary.

DictionaryTemplate is not extended by any other symbol.

Properties

template

Type T

A "template" object to copy all properties from when creating new list items.

1 inherited item
events

Type EventDispatcher <AMEvent <Dictionary <Key, T>, IDictionaryEvents <Key, T>>>Default new EventDispatcher()Inherited from Dictionary

Event dispatcher.

Methods

constructor(t: T)

Returns DictionaryTemplate

Constructor

copyFrom(source: this)

Returns void

Copies all elements from other dictionary.

create(key: Key)

Returns T

Instantiates a new object of the specified type, adds it to specified key in the dictionary, and returns it.

9 inherited items
[Symbol.iterator]()

Returns Iterator <...>Inherited from Dictionary

Returns an ES6 iterator for the keys/values of the dictionary.

clear()

Returns voidInherited from Dictionary

Removes all items from the dictionary.

each(f: (key: Key, value: T) => void)

Returns voidInherited from Dictionary

Calls f for each key/value in the dictionary.

getKey(key: Key)

Returns Optional <T>Inherited from Dictionary

Returns the value for a specific key.

hasKey(key: Key)

Returns booleanInherited from Dictionary

Returns true if key exists in Dictionary.

insertKey(key: Key,
value: T
)

Returns voidInherited from Dictionary

Inserts value at specific key.

Will thrown an exception if the key already exists in the dictionary.

iterator()

Returns Iterator <...>Inherited from Dictionary

Returns an interator that can be used to iterate through all items in the dictionary.

removeKey(key: Key)

Returns voidInherited from Dictionary

Removes value at specific key from dictionary.

setKey(key: Key,
value: T
)

Returns voidInherited from Dictionary

Adds or updates key/value into dictionary.

If the key already exists, the old value will be overwritten.

If the new value is exactly the same as the old value (using ===), it won't do anything.

Events

5 inherited items
cleared

Param { type: "cleared", target: Dictionary }Inherited from Dictionary

Invoked when dictionary is cleared.

insertKey

Param { type: "insertKey", target: Dictionary, key: Key, newValue: Value }Inherited from Dictionary

Invoked when insertKey() method is called.

removed

Param { type: "removed", target: Dictionary, oldValue: Value }Inherited from Dictionary

Invoked when an item is removed from the dictionary.

removeKey

Param { type: "removeKey", target: Dictionary, key: Key, oldValue: Value }Inherited from Dictionary

Invoked when removeKey() method is called.

setKey

Param { type: "setKey", target: Dictionary, key: Key, newValue: Value, oldValue: Value }Inherited from Dictionary

Invoked when setKey() method is called.