Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DynVar<T>

Simple dynamic scope container & implementation.

References:

Type parameters

  • T

Hierarchy

  • DynVar

Implements

  • IDeref<T>
  • IBind<T>
  • ICopy<DynVar<T>>

Index

Constructors

constructor

Methods

bind

  • bind(val: T): boolean
  • Starts new dynamic scope in which given val will be bound to this variable. In most cases, calls to bind() should always be eventually followed by calls to DynVar.unbind to restore this var's previously scoped value.

    Parameters

    • val: T

    Returns boolean

copy

  • Returns new DynVar with this var's current value as its root binding.

    Returns DynVar<T>

deref

  • deref(): any
  • Returns current bound value, i.e. that of the currently active dynamic scope.

    Returns any

set

  • set(val: T): void
  • Replaces current scope's value with new val.

    Parameters

    • val: T

    Returns void

unbind

  • unbind(): boolean
  • Attempts to end the current scope by restoring this var's bound value to that of parent scope. An error is thrown if attempting to remove the root binding.

    Returns boolean

valueOf

  • valueOf(): any

withBinding

  • withBinding<R>(val: T, body: Fn0<R>): R
  • Executes given body function in a new scope which has given val bound to this variable. The new scope is automatically removed when the function returns or an error occurred.

    Type parameters

    • R

    Parameters

    • val: T
    • body: Fn0<R>

    Returns R

Generated using TypeDoc