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

Flowable.create with lambda as last parameter #188

Closed
arekolek opened this issue Jul 13, 2018 · 1 comment
Closed

Flowable.create with lambda as last parameter #188

arekolek opened this issue Jul 13, 2018 · 1 comment

Comments

@arekolek
Copy link
Contributor

How about a function like:

object Flowables {
    inline fun <T> create(
        mode: BackpressureStrategy,
        crossinline source: (FlowableEmitter<T>) -> Unit
    ): Flowable<T> = Flowable.create({ source(it) }, mode)
}

That would let us have code like:

Flowables.create<Int>(BackpressureStrategy.BUFFER) {
    it.onNext(1)
    it.onNext(2)
    it.onNext(3)
}

Instead of:

Flowable.create<Int>({
    it.onNext(1)
    it.onNext(2)
    it.onNext(3)
}, BackpressureStrategy.BUFFER)
@thomasnield
Copy link
Collaborator

Sounds good. Can you put in a PR?

arekolek pushed a commit to arekolek/RxKotlin that referenced this issue Jul 18, 2018

Verified

This commit was signed with the committer’s verified signature.
sebastianbergmann Sebastian Bergmann
thomasnield pushed a commit that referenced this issue Jul 18, 2018

Verified

This commit was signed with the committer’s verified signature.
sebastianbergmann Sebastian Bergmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants