Skip to content
This repository was archived by the owner on Mar 2, 2022. It is now read-only.

SFlux does not have apply(JFlux) #32

Closed
zackman0010 opened this issue Aug 16, 2019 · 8 comments
Closed

SFlux does not have apply(JFlux) #32

zackman0010 opened this issue Aug 16, 2019 · 8 comments

Comments

@zackman0010
Copy link

The SFlux class does not have an apply method that takes a JFlux. This means that, with the removal of the deprecated Flux, there is no longer a way to convert a JFlux to an SFlux.

@rs017991
Copy link
Contributor

@zackman0010 the ScalaConverters class adds implicit asScala methods to JFlux and JMono, so you can do like:

import reactor.core.scala.publisher.ScalaConverters

JFlux.just("whatever").asScala

@sinwe
Copy link
Contributor

sinwe commented Aug 16, 2019

Or another shortcut is
val sFlux = SFlux.fromPublisher(jFlux)

@zackman0010
Copy link
Author

Thank you, I somehow missed that one when I was looking through SFlux last night.

@zackman0010
Copy link
Author

@sinwe If I submitted a merge request to add another apply method to SFlux that simply calls the fromPublisher method, which is the same thing that SMono's apply does, would it be accepted?

@sinwe
Copy link
Contributor

sinwe commented Aug 19, 2019

@zackman0010 You can try and raise PR. I'm not sure if that would be working because of below

object SFlux {
    def apply[T](elements: T*): SFlux[T] = SFlux.fromIterable(elements)
}

When you do SFlux(jFlux) it might be treated as an SFlux with elements on single JFlux instead of converting the JFlux to SFlux.
But I might be wrong. That's just on top of my head.

But it'd be nice if it works because that'll make it consistent with SMono(jMono)

@sinwe sinwe reopened this Aug 19, 2019
@zackman0010
Copy link
Author

zackman0010 commented Aug 19, 2019

You raised a good point, so I went to a scratch sheet to test it out. It looks like, if there's both a T* and a more specific apply function available, it will use the more specific one over the T* one. Not shown in this screenshot is the final test I did where I did not explicitly define the result type (val result5 = Result(testPublisher)). It still ran the Publisher apply method.

image

The test I added on #34 also passed successfully

@sinwe
Copy link
Contributor

sinwe commented Aug 20, 2019

Thanks... I’ll merge your PR soon and I’ll cut a release soon as we’ve got couple of PRs merged to master

@sinwe
Copy link
Contributor

sinwe commented Aug 28, 2019

Released on v0.4.6

@sinwe sinwe closed this as completed Aug 28, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Development

No branches or pull requests

3 participants