BACK
Referenceexpand
Reference · 64

expand

Recursively projects each value into the next Observable.

Signature

expand(project: (value: T, index: number) => ObservableInput): OperatorFunction

What it does

Each value passes on and is also fed into project. The project results go through expand again, until you return EMPTY/a finite stream yourself.

When to use

Paginating to the end, walking a tree/graph, fetching the next page by cursor.

Gotcha

Without a stopping condition, expand easily creates an infinite stream.

See also

mergeMap, EMPTY

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...