-
Notifications
You must be signed in to change notification settings - Fork 39
add withRunner method to EventStream to switch event flow context #74
base: master
Are you sure you want to change the base?
Conversation
Perhaps we should use scala.concurrent.ExecutionContext? |
Maybe the
|
Maybe we just need an On Wed, Jul 10, 2013 at 4:29 PM, Dylan Halperin [email protected]:
|
In that case wouldn't The value I see in using |
How about this:
|
@dylemma see my comment on the google group. Here's the interface of ExecutionContext (docs removed):
If you change So you can easily write an ExecutionContext for SWT a/syncExec, or the AWT event thread, or anything. |
Fair enough. Bonus points if that implicit doesn't need to be explicitly imported. I'm not sure, but maybe if it's defined in EventStream it may work without an import... |
On the other hand, if you're writing a function literal, in order to trigger an implicit conversion you have to write the types explicitly, but if you call the conversion explicitly the types can be inferred. So it's not really buying anything. 1a. |
I'm thinking to address this by using an ADT isomorphic to how RxJava handles success, failure, and END with separate execution paths. Basically foreach(A => Unit) is short for something like observe(Event[A] => Unit) where type Event = Success[A] | Failure | End. |
it could be used to execute events on thread pools, actors, etc.
For example can be used to switch running context to UI thread in android