Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GlobalsService

The GlobalsService tracks changes in dashboard-level global variables. This class exposes a hook for listening to changes in Globals, getters and setters for individual globals, and facilities for evaluating binding expressions.

Binding Expressions are short snippets of kernel code, that allows Globals to be referenced directly. When these globals are referenced, consumers can re-run those expressions in response to changes in global values.

Hierarchy

  • GlobalsService

Implements

  • IDirtyable
  • IDisposable
  • Iterable<Readonly<IGlobal>>

Index

Type aliases

Static IChangeType

IChangeType: "add" | "rename" | "update" | "delete" | "cast"

Constructors

constructor

Properties

OnChange

OnChange: Observable<IGlobalChange>

An Observable that fires whenever the value of a single global has changed.

The value emitted contains the old state, new state, and the type of change that occurred.

This fires asynchronously, within the same VM turn as a global change.

Private OnChangeSrc$

OnChangeSrc$: Subject<object> = new Subject<Readonly<GlobalsService.IGlobalChange>>()

OnDirty

OnDirty: Observable<void>

An Observable that fires once the globals become dirty. It will not fire again until setClean() is called.

Private OnDirtySrc$

OnDirtySrc$: Subject<void> = new Subject<void>()

Private _isDirty

_isDirty: boolean = false

Private _isDisposed

_isDisposed: boolean = false

Private globalValues

globalValues: Map<string, object> = new Map<string, Readonly<GlobalsService.IGlobal>>()

Accessors

isDirty

  • get isDirty(): boolean

isDisposed

  • get isDisposed(): boolean

Methods

__@iterator

  • __@iterator(): IterableIterator<object>

Private _ensureGlobalExists

  • _ensureGlobalExists(globalName: string): void

Private _setOrAddGlobal

  • _setOrAddGlobal<T>(globalName: string, globalType: Type, globalValue: T, action: IChangeType): void

addGlobal

  • addGlobal<T>(globalName: string, globalType: Type, globalValue: T): void
  • Add a new global variable to the GlobalsService.

    throws

    if the GlobalsService already has a global with the given globalName

    Type parameters

    • T

    Parameters

    • globalName: string
    • globalType: Type
    • globalValue: T

    Returns void

changeType

  • changeType(globalName: string, newType: Type): void
  • Change the type annotation of a global variable. If the types are incompatible, the value of the global will be cleared and set to null.

    throws

    if the global to change doesn't exist

    Parameters

    • globalName: string
    • newType: Type

    Returns void

clearGlobals

  • clearGlobals(): void
  • Clear all globals and reset state.

    Notes

    This is called whenever the model providing global definitions has changed.

    Returns void

dispose

  • dispose(): void

get

  • get(globalName: string): unknown
  • Return the current value of a single Global.

    throws

    Error if there is no global having the given name

    Parameters

    • globalName: string

    Returns unknown

getType

  • getType(globalName: string): Type
  • Returns the type annotation of a single Global

    throws

    Error if there is no global having the given name

    Parameters

    • globalName: string

    Returns Type

has

  • has(globalName: string): boolean
  • Test if the globals service has a particular global.

    Parameters

    • globalName: string

    Returns boolean

removeGlobal

  • removeGlobal(globalName: string): void
  • Removes a global from the GlobalsService

    throws

    if the GlobalsService doesn't have a global by the given name

    Parameters

    • globalName: string

    Returns void

renameGlobal

  • renameGlobal(globalName: string, newName: string): void
  • Change the global name.

    throws

    if no global exists by globalName, or if a global already exists at newName

    Parameters

    • globalName: string
    • newName: string

    Returns void

set

  • set(globalName: string, newValue: unknown): void
  • Set the value of a global, triggering update notifications in the same VM turn. If the new value does not strictly equal the old value, the change will not be committed and no event will be fired.

    throws

    Error if there is no global having the given name

    Parameters

    • globalName: string
    • newValue: unknown

    Returns void

setClean

  • setClean(): void

Private setDirty

  • setDirty(): void

Generated using TypeDoc