Hello! I have a use case where I need to get data out of client side storag

Hello!
I have a use case where I need to get data out of client side storage in a more synchronous manner. I attempted creating a variable and waiting for it to be set inside of the closure provided to getSessionItem. For some reason, I never see the variable being set.
Something to note… If I do not use this method but instead load my variable and print it inside the closure then let my code move on, I do later see the variable in my console.
Is there a more reliable way to wait for the closure to have been run before moving on?
Here is some example code that demonstrates what I’m trying to do.

Example Code:
void printSessionInfo() {
String value = null
ui.clientStorage.getSessionItem(“key”, {
value = it
})
while(value==null){println(“Sleeping!”)
sleep(5)}
println(value)
}