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
- ObservedEnum
- new ObservedEnum(value, validSet)
- .onChanged :
Signal.<T, T> - .getValidValueSet() ⇒
Object.<string, T> - .set(value) ⇒
ObservedEnum - .equals(other) ⇒
boolean - .hash() ⇒
number - .copy(other)
- .getValue() ⇒
T - .process(processor, [thisArg]) ⇒
this
new ObservedEnum(value, validSet)
| Param | Type |
|---|---|
| value | T |
| validSet | Object.<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
| Param | Type |
|---|---|
| value | T |
observedEnum.equals(other) ⇒ boolean
Kind: instance method of ObservedEnum
| Param | Type |
|---|---|
| other | ObservedEnum.<T> |
observedEnum.hash() ⇒ number
Kind: instance method of ObservedEnum
observedEnum.copy(other)
Kind: instance method of ObservedEnum
| Param | Type |
|---|---|
| other | ObservedEnum |
observedEnum.getValue() ⇒ T
Kind: instance method of ObservedEnum
observedEnum.process(processor, [thisArg]) ⇒ this
Kind: instance method of ObservedEnum
| Param | Type |
|---|---|
| processor | function |
| [thisArg] | * |