Options
All
  • Public
  • Public/Protected
  • All
Menu

An InterpolatedString is a string with placeholder variables on the form ${varName}, and extends Observable<string | undefined>, making it an Observable which emits the string with the placeholders replaced by actual string values. New subscribers will immediately receive the current value, if any, akin to a ReplaySubject(1).

Hierarchy

  • Observable<string | undefined>
    • InterpolatedString

Index

Constructors

Methods

Constructors

constructor

  • Takes a string with embedded placeholders on the form ${varName}.

    Parameters

    • template: string

    Returns InterpolatedString

Methods

bindTo

  • Binds an Observable of a data object to this InterpolatedString, calling resolve when data arrives on the given Observable.

    Note: This is largely the same as subscribing to the Observable and calling resolve with the received object, but differs in only subscribing to the Observable if and when there are listeners subscribed to this InterpolatedString.

    Parameters

    • values: undefined | Observable<{}>

    Returns InterpolatedString

resolve

  • resolve(values: {}): undefined | string
  • Resolves the placeholders in the InterpolatedString with the key/values of the object given. If all placeholders are resolved, and there are any changed to the resulting string, the InterpolatedString will emit the string. If not all placeholders are given in the object, and the InterpolatedString has previously emitted a string, it will emit undefined.

    Note: Be aware that resolve(...) is stateless in the sense that it does not remember and accumulate previous keys/values. The placeholders are resolved against the object as given. If you want to accumulate properties one at a time from different sources, use a PartialObject.

    Parameters

    • values: {}
      • [key: string]: any

    Returns undefined | string