Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. // uni
  2. public interface Uni<T> {
  3. static Uni<T> fromCompletionStage(CompletionStage<T> foo);
  4. CompletionStage<T> subscribeToCompletionStage(); // start the execution eagerly (should it be named subscribeAndComplete)
  5. U to(Class<U> clazz); // converts to whatever like Mono
  6. U more(Class<U> clazz); // converts to whatever like Mono
  7. ...
  8. // add operators
  9. }
  10.  
  11. public class UniImpl extends CompletionStageImp implements Uni {
  12. ..
  13. }
  14.  
  15. class SomeMPAPI {
  16. CompletionStage<Foo> bar();
  17. }
  18.  
  19. class SomeQuarkusAPI {
  20. Uni<Foo> baz() { } ;
  21. }
  22.  
  23. class SomeUserCode {
  24. void someMethod() {
  25. fromCompletionStage(someMPAPI.bar()).uniWizbang();
  26. someQuarkusAPI.baz().to(Single.class).rxWizbang();
  27. someQuarkusAPI.more(ExtraOperators.class).extraOperatorWizbang();
  28.  
  29. // alternative of parallel classes from MP
  30. someMPApi.unwrap(SomeQuarkusMPApi.class).bar().uniWizbang();
  31. }
  32. }
  33.  
  34. //options
  35. // [ ] Add a unwrap() on Uni to allow "more" operators
  36.  
  37. interface Multi extends Flow.Publisher {
  38. // add operators
  39. static Multi<T> fromPublisher(Flow.Publisher<T> foo);
  40. U to(Class<U> clazz); // converts to whatever like Flux
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement