Skip to main content

ObservedEnum

ObservedEnum

Enumerable value abstraction. Think enum keyword in TypeScript or any other programming language. Given a set of valid values, holds one of such values. This is an observable value, meaning you can subscribe to be notified of changes via onChanged signal.

Kind: global class

new ObservedEnum(value, validSet)

ParamType
valueT
validSetObject.<string, T>

Example

const v = new ObservedEnum(7, {
ONE: 1,
SEVEN: 7
});

v.getValue(); // 7

v.set(1);

v.getValue(); // 1

v.set(2); // will throw error, as 2 is not a valid enum value

observedEnum.onChanged : Signal.<T, T>

Kind: instance property of ObservedEnum
Read only: true

observedEnum.getValidValueSet() ⇒ Object.<string, T>

Do not modify result

Kind: instance method of ObservedEnum

observedEnum.set(value) ⇒ ObservedEnum

Kind: instance method of ObservedEnum

ParamType
valueT

observedEnum.equals(other) ⇒ boolean

Kind: instance method of ObservedEnum

ParamType
otherObservedEnum.<T>

observedEnum.hash() ⇒ number

Kind: instance method of ObservedEnum

observedEnum.copy(other)

Kind: instance method of ObservedEnum

ParamType
otherObservedEnum

observedEnum.getValue() ⇒ T

Kind: instance method of ObservedEnum

observedEnum.process(processor, [thisArg]) ⇒ this

Kind: instance method of ObservedEnum

ParamType
processorfunction
[thisArg]*