Link Search Menu Expand Document

Track Processing State of Stores

When one of your Handlers contains long running actions (like server-calls, etc.) you might want to keep the user informed about that something is going on.

Using fritz2 you can use the tracker-service to implement this:

val store = object : RootStore<String>("") {
    val tracking = tracker()

    val save = handle { model ->
        tracking.track("myTransaction") {
            delay(1500) // do something that takes a while

render {
    button("btn") {
        className( {
            if(it) "spinner" else ""
        clicks handledBy

The service provides you with a Flow representing the description of the currently running transaction or null.

Filter the Flow using the meta-data you chose when calling track(meta-data) if you want to react to only certain transactions.

Of course, you can also use the meta-data to show to the user what is currently running (in a status-bar for example).

Our repositories example uses tracking, to show you a spinning wheel when you click on the save button.

Distributed by a MIT license.