This interface identifies the config which can track changes

interface IDynamicConfigHandler<T> {
    blkVal: (<C, V>(target: C, name: string) => V);
    cfg: T;
    logger: IDiagnosticLogger;
    notify: (() => void);
    rdOnly: (<C, V>(target: C, name: string) => V);
    ref: (<C, V>(target: C, name: string) => V);
    set: (<C, V>(theConfig: C, name: string, value: V) => V);
    setDf: (<C>(theConfig: C, defaultValues: IConfigDefaults<C, T>) => C);
    uid: string;
    watch: ((configHandler: WatcherFunction<T>) => IWatcherHandler<T>);
}

Type Parameters

Properties

blkVal: (<C, V>(target: C, name: string) => V)

Set the value that is or will be assigned to this named property of the target will not have it's properties converted into dynamic properties, this means that any changes the values properties will not be monitored for changes and therefore will not cause any listeners to be notified in any value is changed. If the value associated with the target[name] is change this is still dynamic and will cause listeners to be notified.

Type declaration

    • <C, V>(target, name): V
    • Type Parameters

      • C
      • V = any

      Parameters

      • target: C

        The object which has (or will have) the named property

      • name: string

        The name of the property in the target

      Returns V

      The referenced properties current value.

let localValue = target[name];   // If within a listener this will cause the listener to be called again
target[name] = newValue; // This will notify listeners that accessed target[name]

// This will not cause lsiteners to be called because propa is not converted and value of target[name]
// did not change.
target[name].propa = 1;
target[name].propb = 2;

// If within a listener this will caused the listener to be called again only if target[name] is reassigned
// not if the value associated with propa is changed.
let localValue = target[name].propa;
cfg: T

Link back to the configuration object that should be used to get/set values

The logger instance to use to logger any issues

notify: (() => void)

Helper to call any listeners that are waiting to be notified

rdOnly: (<C, V>(target: C, name: string) => V)

Set this named property of the target as read-only, which will block this single named property from ever being changed for the target instance. This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property, if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.

Type declaration

    • <C, V>(target, name): V
    • Type Parameters

      • C
      • V = any

      Parameters

      • target: C

        The object which has (or will have) the named property

      • name: string

        The name of the property in the target

      Returns V

      The referenced properties current value.

ref: (<C, V>(target: C, name: string) => V)

Set this named property of the target as referenced, which will cause any object or array instances to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.

Type declaration

    • <C, V>(target, name): V
    • Type Parameters

      • C
      • V = any

      Parameters

      • target: C

        The object which has (or will have) the named property

      • name: string

        The name of the property in the target

      Returns V

      The referenced properties current value.

set: (<C, V>(theConfig: C, name: string, value: V) => V)

Set the value against the provided config/name with the value, the property will be converted to be dynamic (if not already) as long as the provided config is already a tracked dynamic object.

TypeError if the provided config is not a monitored dynamic config

setDf: (<C>(theConfig: C, defaultValues: IConfigDefaults<C, T>) => C)

Set default values for the config if not present.

Type declaration

    • <C>(theConfig, defaultValues): C
    • Type Parameters

      • C

      Parameters

      • theConfig: C

        The configuration object to set default on (if missing)

      • defaultValues: IConfigDefaults<C, T>

        The default values to apply to the config

      Returns C

uid: string

Unique Id for this config handler

watch: ((configHandler: WatcherFunction<T>) => IWatcherHandler<T>)

Watch and track changes for accesses to the current config anb