toFlow

@ExperimentalCoroutinesApi
fun <T> SubscriptionBuilder<T>.toFlow(): Flow<T>

Like SubscriptionBuilder.observer, but emits data changes to the returned flow. Automatically cancels the subscription when the flow is canceled.

For example to create a flow to listen to all changes to a box:

store.subscribe(TestEntity::class.java).toFlow()

Or to get the latest query results on any changes to a box:

box.query().subscribe().toFlow()