Skip to content

Typing error when wrapping useObservable with generic #46

@dfee

Description

@dfee
import { useObservable } from "rxjs-hooks";
import { map  } from "rxjs/operators";

export const useAsync = <State, Inputs extends any[]>(
  fn: (...args: Inputs) => State,
  deps: Inputs,
) =>
  useObservable<State, Inputs>(
    inputs$ =>
      inputs$.pipe(
        map(i => {
          return (i as unknown) as State;
        }),
      ),
    [0, 1, 2],
    deps,
  );

Results in the following:
image

It seems that passing generic values for useObservable isn't supported. Any ideas?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions