I'm sorry for the multiple issues. I've just started integrating this into an app. This one would probably be trivial to implement in my app, but it might be nice to have as part of the API.
Something like:
inline fun <reified T> Config.observe(item: Item<T>): Flow<T> =
callbackFlow {
send(get(item))
val handler = afterSet { updatedItem, value ->
if (updatedItem == item && value is T) trySend(value)
}
awaitClose { handler.cancel() }
}
edit: updated code for tested/working version
I'm sorry for the multiple issues. I've just started integrating this into an app. This one would probably be trivial to implement in my app, but it might be nice to have as part of the API.
Something like:
edit: updated code for tested/working version