Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OptionsBag

Stores the values of part options, and allows parts to get and set part values.

OptionsBags are passed on render to parts, and are paired with the part.

Hierarchy

  • OptionsBag

Implements

Index

Constructors

constructor

Properties

OnOptionChanged

OnOptionChanged: Observable<PartOptionChange>

Private OnOptionChangedSrc$

OnOptionChangedSrc$: Subject<PartOptionChange> = new Subject<OptionsBag.PartOptionChange>()

Private _isDisposed

_isDisposed: boolean = false

Private _isStale

_isStale: boolean = false

Private errorOptions

errorOptions: Map<string, PartOption> = new Map<string, OptionsBag.PartOption>()

Private optionsMap

optionsMap: Map<string, PartOption> = new Map<string, OptionsBag.PartOption>()

Private staleOptions

staleOptions: Map<string, PartOption> = new Map<string, OptionsBag.PartOption>()

Accessors

isDisposed

  • get isDisposed(): boolean

isStale

  • get isStale(): boolean

Methods

__@iterator

clearBinding

  • clearBinding(name: string): void
  • Remove a binding from an option This will stale the option.

    Parameters

    • name: string

    Returns void

clearError

  • clearError(): void
  • Clears any errored options from this bag.

    Options are marked as 'errored' to keep them out of the staleness loop. This allows option changes to result in re-evaluations, while preserving some way of marking these options as needing to be evaluated.

    Returns void

dispose

  • dispose(): void

Private ensureOption

  • ensureOption(name: string): void

get

  • get(name: string): unknown
  • Retrieve the value of an option.

    throws

    if the option specified doesn't belong to this options bag

    Parameters

    • name: string

    Returns unknown

getMetadata

  • Return the metadata about an option; including it's type and name.

    throws

    if name is not a valid option

    Parameters

    • name: string

    Returns PartOption

getStaleOptionValues

  • getStaleOptionValues(): Iterable<[string, PartOption]>

getStaleOptions

  • getStaleOptions(): Iterable<string>

Private mergeStaleness

set

  • set(name: string, value: unknown): void
  • Sets the value of the given option. The part option is staled, and the new value is set. If the value is an EvalBinding, the change is silently rejected. Otherwise, the PartManager will set the bound global once it recieves the staleness.

    throws

    if the option specified doesn't belong to this options bag

    Parameters

    • name: string
    • value: unknown

    Returns void

setAllOptionsStale

  • setAllOptionsStale(): void
  • Marks all options as stale.

    This will cause the framework to re-evaluate all of them, which is useful for "Refresh Part". This ensures that all options are up to date and surfaces an escape hatch for the user if they know that the data is stale.

    Returns void

setBinding

  • setBinding(name: string, type: string, expr: string, globals?: ReadonlyArray<string>): void
  • Bind an option to a global, or binding expression. When setting an eval binding, include the list of globals referenced in the expression. Setting a binding will stale it.

    throws

    if the option name isn't a valid option

    Parameters

    • name: string
    • type: string
    • expr: string
    • Optional globals: ReadonlyArray<string>

    Returns void

setBindingValue

  • setBindingValue(name: string, value: unknown): void

setError

  • setError(erroredOptions: Iterable<string>): void
  • Parameters

    • erroredOptions: Iterable<string>

    Returns void

setFresh

  • setFresh(): void

setStale

  • setStale(staleOptions?: Iterable<[string, PartOption]>): void

values

  • values(): IterableIterator<unknown>

Generated using TypeDoc