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

Type signature of combine #28

Closed
AlexGalays opened this issue Apr 30, 2016 · 4 comments
Closed

Type signature of combine #28

AlexGalays opened this issue Apr 30, 2016 · 4 comments

Comments

@AlexGalays
Copy link
Contributor

It seems combine has a wrong type signature, at least when used statically from the Stream object.

Using it with just two streams, the project function expects 3 arguments?

import xs from 'xstream'

const stream = Stream.create<string>({
    start: listener => {},
    stop: () => {}
})

const stream2 = Stream.create<string>({
    start: listener => {},
    stop: () => {}
})

const combined = Stream.combine(
    (a, b) => a.slice(2) + b.slice(2),
    stream, stream2
)

This doesn't compile, because the a passed to the project function is inferred to be an object.

@staltz
Copy link
Owner

staltz commented Apr 30, 2016

For the static combine, use xs.combine, not Stream.combine.

xs.combine(fn, a, b) then fn expects 2 args

streamInstance.combine(fn, a, b) then fn expects 3 args.

Does this solve your case?

@AlexGalays
Copy link
Contributor Author

Isn't xs and Stream exactly the same?

In my own code, I use

import xs from 'xstream'
xs.combine...

Only had to use Stream on the typescript playground.

@staltz
Copy link
Owner

staltz commented Apr 30, 2016

Ok, sorry, I think it's actually incorrect in code. I'll fix this.

staltz added a commit that referenced this issue Apr 30, 2016
Was lacking some important pieces.

For issue #28.
@staltz
Copy link
Owner

staltz commented Apr 30, 2016

Released v2.1.2 with a fix

@staltz staltz closed this as completed Apr 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants