kezhenxu94 removed a comment on issue #3585:
URL: https://github.com/apache/dubbo/issues/3585#issuecomment-469687420


   I'm wondering:
   - whether the proposed definition will result to the [Callback 
Hell](https://en.wiktionary.org/wiki/callback_hell), many programming languages 
tried to avoid **Callback Hell** such as `Future` in Java and `Promise` in 
Javascript
   - and the proposed definition seems make it difficult to synchronous calls 
(in case that users need it, let's leave it possible for synchronous calls)
   
   Can we borrow the design from The Netty Project, say returning a 
`org.apache.dubbo.filter.Future` that is declared like below:
   
   ```java
   class Future<T> {
     T get(); // wait for the result synchronously
     void onComplete(SomeContext c); // asynchronously
     void onSend(SomeContext c); // asynchronously
     void onError(SomeContext c); // asynchronously
     // ... other callbacks
   }
   ```
   
   then users can do something like this:
   ```java
   Filter filter = ...;
   Future f = filter.invoke(...);
   // if synchronous call is needed
   f.get();
   // if asynchronous call is needed
   f.onSend(context -> { /* lambda */ });
   f.onError(context -> { /* lambda */ });
   // ... others
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to