com.wire.signals.ui
Type members
Classlikes
This is a utility class to help you set up wire-signals to transport events between the default execution context
(Threading.defaultContext
) and other custom contexts, and a secondary execution context usually associated with GUI.
On platforms such as Android or JavaFX, a Runnable
task that involves changes to the app's GUI requires to be run
in a special execution context - otherwise it will either not work, will result in errors, or may even crash the app.
Your platform should provide you with a method which you can call with the given task to execute it properly.
If that method is of the type Runnable => Unit
(or if you can wrap it in a function of this type) you can pass it
to UiDispatchQueue
in the app's initialization code. Later, UiDispatchQueue
will let you use extension methods
.onUi
on event streams and signals. They work exactly like .foreach
but they will run the subscriber code in
your GUI platform execution context.
This is a utility class to help you set up wire-signals to transport events between the default execution context
(Threading.defaultContext
) and other custom contexts, and a secondary execution context usually associated with GUI.
On platforms such as Android or JavaFX, a Runnable
task that involves changes to the app's GUI requires to be run
in a special execution context - otherwise it will either not work, will result in errors, or may even crash the app.
Your platform should provide you with a method which you can call with the given task to execute it properly.
If that method is of the type Runnable => Unit
(or if you can wrap it in a function of this type) you can pass it
to UiDispatchQueue
in the app's initialization code. Later, UiDispatchQueue
will let you use extension methods
.onUi
on event streams and signals. They work exactly like .foreach
but they will run the subscriber code in
your GUI platform execution context.
Examples:
Android initialization:
import android.os.{Handler, Looper}
import com.wire.signals.ui.UiDispatchQueue
val handler = new Handler(Looper.getMainLooper)
UiDispatchQueue.setUi(handler.post)
JavaFX initialization:
import javafx.application.Platform
import com.wire.signals.ui.UiDispatchQueue
UiDispatchQueue.setUi(Platform.runLater)
Usage in all cases:
import com.wire.signals.ui.UiDispatchQueue._
signal ! true
signal.onUi { value => ... }
Future { ... }(Ui)
- Value Params
- runUiWith
A function from the GUI platform you're working with that will execute a given task in the GUI context
- Companion
- object