Skip to main content

reactiveTemplateString

Alternative: string$$

Types

function reactiveTemplateString(
parts: TemplateStringsArray | string[],
...observables: IObservable<any>[]
): IObservable<string>

Definition

Creates an Observable from a template literal. If any of the members (Observables) of the template string change, it re-generates the string and send it.

Diagram

Example

Compute the fullname of a user from its firstname and lastname

const firstname$ = single('Valentin');
const lastname$ = single('Richard');

const fullname$ = reactiveTemplateString`${firstname$} ${lastname$}`;

fullname$((value: boolean) => {
console.log(value);
});

Output:

Valentin Richard