I have converted my application to use redux (the ...
# kvision
l
I have converted my application to use redux (the JS version). It is very neat. 🙂 I am doing a few api calls, and need to display a loading indication/spinner to the user. Have you got an example how that can be done?
r
you can use kvision-pace module
it should work out of the box for typical api calls
but if you want more manual control i'm using it this way:
Initialization:
Copy code
Pace.init(require("pace-progressbar/themes/blue/pace-theme-corner-indicator.css"))
        Pace.setOptions(PaceOptions(manual = true))
helper function:
Copy code
var paceCounter = 0

suspend fun <T> withProgress(block: suspend () -> T): T {
    Pace.show()
    paceCounter++
    return try {
        block()
    } finally {
        paceCounter--
        if (paceCounter <= 0) Pace.hide()
    }
}
l
Works like charm 👍