-
Notifications
You must be signed in to change notification settings - Fork 123
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
Uni.invoke() (or call() or handle()) #146
Comments
This issue came a few times. I, first, need to understand the use case, as most of the time, I've seen these methods used just for We want to add a log operator:
The log operator can log automatically (using a predefined log statement) or be used with a callback returning the String to be logged. If requested, the log should be able to clean up the stack trace to be meaningful. When not used for logging, these methods are often used to implement side-effects. While they cannot be discarded, users must be a bit careful with that. About the naming, what about |
This isn't anything to do with logging. (For logging I would need a matching method that is called on failures.) It's specifically in order to be able to call side-effects, which are rather hugely important when one is writing data-access code. :-) The most basic operations like
I want something that looks and feels visually like |
You could call it |
I like that name! @jponge @kenfinnigan WDYT? |
Is this the same as |
Some random ideas:
|
|
And |
Yeah, I thought about it over lunch 🤦 |
In fairness, it's probably the least used keyword except for |
I kind of like Some other options could be |
|
|
I dunno, "peek" sounds kinda like the opposite of what this is. "Peek" sounds like something with no side-effect, whereas we've already established that the whole point of this operation is to do side effects. |
I'd be totally happy with calling it "poke", however. 😝 |
Will poke get me infinite threads?
…On Mon, 1 Jun 2020, 22:17 Gavin King, ***@***.***> wrote:
I dunno, "peek" sounds kinda like the opposite of what this is.
I'd be totally happy with calling it "poke", however. 😝
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#146 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANKF2GHSWMNCFXSMEF7QBLRUQEG3ANCNFSM4NI76VLA>
.
|
But |
Sure, but I'm not writing a code that produces a processing pipeline. I'm writing code that does something interesting to the world. I DGAF what this operation does to the stream, since my program isn't about streams. |
Yea, well, you do. If you use the |
That's the myopic perspective of the designer of a reactive streams library. It's not my perspective as a user of the API. I'm trying to make an interesting program that does useful things. I actually don't care about reactive streams at all. When I look at my code I want to see information about how my program solves the problem the program is designed to solve. Not information about reactive streams. |
And that's why
while surely very cool and elegant, arguably, to someone who's very myopically interested in reactive streams, is quite intrusive and annoying in my program which does interesting stuff that end users care about. |
Actually it's a perspective of someone who hates reactive programming libraries and believes that if we really need to impose them on users, then we shouldn't try to hide what's really going on, because leaking abstraction etc. etc. etc. But I'm ready to agree to disagree. |
Well, I'm trying to find a way to hate it slightly less. |
Alright, so reflecting on @Ladicek point about So why don't I like So why not call the operation |
Hear me out on this one. This reads really naturally, I think: return factory.withSession(
session -> session.find(Book.class, bookId)
.use(book -> session.remove(book))
.map(book -> "deleted " + book.title)
); |
Kotlin has also return factory.withSession(
session -> session.find(Book.class, bookId)
.also(book -> session.remove(book))
.map(book -> "deleted " + book.title)
); |
I am sure that every designer of the stream library had the same discussion. We already have a standard Java library. While some names may be less than perfect, they are well known and understood, so why not just stick with that? Easy to use reactive library is something to be excited about; a slightly better name for functionality that I already know under a different name is not. |
Ummmmm, because the other APIs are terrible, and terribly confusing? |
We have tried to use the names from java.util.Stream in MicroProfile reactive streams ops. Feedback has not been good. While "known" it's just confusing and didn't work well (confusing names, hard to find the proper method...). |
|
After some experience I find I prefer the
map()
/flatMap()
API toonItem()
.But it's really annoying that there's no equivalent shortcut way to call
UniOnItem.invoke()
, since it's an operation I use all the time.I would like to see
invoke()
added toUni
, though perhaps it would make more sense to name ithandle()
, since it's a sort of event handlery thing. Orcall()
perhaps.The text was updated successfully, but these errors were encountered: