@OptIn(ExperimentalCoroutinesApi::class) class SyncButtonBinding( tabsTrayStore: TabsTrayStore, private val onSyncNow: () -> Unit, ) : AbstractBinding<TabsTrayState>(tabsTrayStore) { override suspend fun onState(flow: Flow<TabsTrayState>) { flow.map { it.syncing } .ifChanged() .collect { syncingNow -> if (syncingNow) { onSyncNow() } } } }
An [AbstractBinding] that invokes the [onSyncNow] callback when the [TabsTrayState.syncing] is set.