wonderful world
wonderful world

Reputation: 11599

What this typescript method signature in the picture mean?

The following code is taken from the ngrx example. The intellisense for the method store.select has a long signature with two arrows. What does this method signature mean?

The type definition file shows this signature:

export interface SelectSignature<T> { <R>(...paths: string[]): Observable<R>; <R>(mapFn: (state: T) => R): Observable<R>; }

enter image description here

Upvotes: 0

Views: 80

Answers (1)

Richard Szalay
Richard Szalay

Reputation: 84734

It means that it can either be:

  1. A function that accepts some or more paths and returns an Observable of R values
  2. A function that accepts a mapping function and returns an Observable of R values. The mapping function accepts T values and returns an appropriate R value.

Upvotes: 1

Related Questions