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

Allow compose transformer return arbitrary type #207

Closed
wclr opened this issue Jul 13, 2017 · 3 comments
Closed

Allow compose transformer return arbitrary type #207

wclr opened this issue Jul 13, 2017 · 3 comments

Comments

@wclr
Copy link
Contributor

wclr commented Jul 13, 2017

Currently compose requires that returned value was a stream of transformed values.

What about allowing to return arbitrary type of value?

const partition = <T>(predicate: (item: T) => boolean) =>
  (stream: Stream<T>) => [
    stream.filter(predicate),
    stream.filter(item => !predicate(item))
  ]

// this would allow such syntax
const [good$, bad$] = source$.compose(partition(filterGood))

// vs 

const [good$, bad$] = partition(filterGood)(source$)

Or you see compose as strictly Stream to Stream transformation function? (though JS without TS version still allows to do this)

@staltz
Copy link
Owner

staltz commented Jul 13, 2017

@whitecolor This is interesting. I thought it would hurt typings elsewhere, but I gave it a try, and we can easily do this with zero difference for JS users, and no breaking changes for anyone (JS or TS users). It's just a backwards compatible feature. It's an easy win, so why not.

@staltz
Copy link
Owner

staltz commented Jul 13, 2017

It's so easy, I just did it. Released in v10.9

@wclr
Copy link
Contributor Author

wclr commented Jul 13, 2017

Great. This allows more flexible operators. BTW what do you is partition operator needed in extras? I quite often find it in a need.

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