Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ObservedValueUnion/TupleFromArray #5254

Merged
merged 3 commits into from
Jan 23, 2020

Conversation

cartant
Copy link
Collaborator

@cartant cartant commented Jan 22, 2020

Description:

This PR:

  • Renames the ObservedValuesFromArray type to ObservedValueUnionFromArray and deprecates the former.
  • Adds the ObservedValueTupleFromArray type.

The differences between the two are best shown by example:

type S = Observable<string>;
type N = Observable<number>;
ObservedValueUnionFromArray<[S, N]> // string | number
ObservedValueTupleFromArray<[S, N]> // [string, number]

It also adds an Unshift type - which adds a type to the beginning of a tuple - that should be useful in typing the combineLatestWith and zipWith operators.

These types should be sufficient to allow for N-args support in those operators:

export function zipWith<T, A extends ObservableInput<any>[]>(
  ...otherSources: A
): OperatorFunction<T, Unshift<ObservedValueTupleFromArray<A>, T>>;

Related issue PRs: #5249; #5251

@cartant cartant requested a review from benlesh January 22, 2020 06:10
@cartant cartant changed the title feat: add ObservableValueUnion/TupleFromArray feat: add ObservedValueUnion/TupleFromArray Jan 22, 2020
@cartant cartant force-pushed the observable-value-tuple branch 2 times, most recently from cc6c979 to c6c0afe Compare January 22, 2020 19:59
* Adds a type to the beginning of a tuple.
* If you pass in `Unshift<[B, C], A>` you will get back `[A, B, C]`.
*/
export type Unshift<X extends any[], Y> =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I wouldn't have thought to use extending a function to pull out the argument types. Very cool

@cartant cartant merged commit 338b174 into ReactiveX:master Jan 23, 2020
kwonoj pushed a commit to kwonoj/rxjs that referenced this pull request Feb 5, 2020
* feat: add observed value union and tuple types

* chore: rename to use observed value union type

* chore: tweak test to make dtslint deterministic

For some reason, the number[] type shows up in seemingly random places
in the union.
martinsik pushed a commit to martinsik/rxjs that referenced this pull request Feb 15, 2020
* feat: add observed value union and tuple types

* chore: rename to use observed value union type

* chore: tweak test to make dtslint deterministic

For some reason, the number[] type shows up in seemingly random places
in the union.
@lock lock bot locked as resolved and limited conversation to collaborators Feb 22, 2020
@cartant cartant deleted the observable-value-tuple branch September 24, 2020 07:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants