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

Stream.zipLatestAll #2718

Open
dilame opened this issue May 9, 2024 · 0 comments · Fixed by #2832
Open

Stream.zipLatestAll #2718

dilame opened this issue May 9, 2024 · 0 comments · Fixed by #2832
Labels
enhancement New feature or request

Comments

@dilame
Copy link
Contributor

dilame commented May 9, 2024

What is the problem this feature would solve?

We have an extremely useful Stream.concatAll and Stream.mergeAll functions, but we don't have the same concept for zipping latest values.

What is the feature you are proposing to solve the problem?

Implement

type ZipLatestAllValues<T extends Array<Stream<unknown, unknown, unknown>>> = { [K in keyof T]: T[K] extends Stream<infer U> ? U : never }
type ZipLatestAllErrors<T extends Array<Stream<unknown, unknown, unknown>>> = T extends Array<Stream<unknown, infer E, unknown>> ? E : never;
type ZipLatestAllContext<T extends Array<Stream<unknown, unknown, unknown>>> = T extends Array<Stream<unknown, unknown, infer R>> ? R : never;

export declare const zipLatestAll: {
    <A extends Array<Stream<unknown, unknown, unknown>>>(...streams: A): Stream<ZipLatestAllValues<A>,  ZipLatestAllErrors<A>, ZipLatestAllContext<A>>;
};

// Stream.Stream<[number, string, boolean], never, never>
const latest = Stream.zipLatestAll(Stream.make(1,2,3), Stream.make('a','b','c'), Stream.make(true,false))

What alternatives have you considered?

No response

@dilame dilame added the enhancement New feature or request label May 9, 2024
@dilame dilame mentioned this issue May 23, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant