Skip to content

//reactivestate-core/com.ensody.reactivestate/coAutoRun

coAutoRun

[common]\ fun CoroutineLauncher.coAutoRun(onChange: CoAutoRunOnChangeCallback<Unit>? = null, flowTransformer: AutoRunFlowTransformer = { conflatedWorker(transform = it) }, dispatcher: CoroutineDispatcher = dispatchers.main, withLoading: MutableValueFlow<Int>? = loading, observer: CoAutoRunCallback<Unit>): CoAutoRunner<Unit>

Watches observables for changes. Often useful to keep things in sync (e.g. CoroutineLauncher -> UI).

This is a convenience function that immediately starts the AutoRunner.run cycle for you.

Returns the underlying AutoRunner. To stop watching, you should call AutoRunner.dispose. The AutoRunner is automatically disposed when the CoroutineLauncher’s scope completes.

See AutoRunner for more details.

Parameters

common

onChange Gets called when the observables change. If you provide a handler you have to manually call run.
flowTransformer How changes should be executed/collected. Defaults to conflatedWorker.
dispatcher The CoroutineDispatcher to use. Defaults to dispatchers.main.
withLoading Tracks loading state for the (re-)computation. Defaults to CoroutineLauncher.loading.
observer The callback which is used to track the observables.

[common]\ fun CoroutineScope.coAutoRun(launcher: CoroutineLauncher = SimpleCoroutineLauncher(this), onChange: CoAutoRunOnChangeCallback<Unit>? = null, flowTransformer: AutoRunFlowTransformer = { conflatedWorker(transform = it) }, dispatcher: CoroutineDispatcher = dispatchers.main, withLoading: MutableValueFlow<Int>? = launcher.loading, observer: CoAutoRunCallback<Unit>): CoAutoRunner<Unit>

Watches observables for changes. Often useful to keep things in sync (e.g. ViewModel -> UI).

This is a convenience function that immediately starts the AutoRunner.run cycle for you.

Returns the underlying AutoRunner. To stop watching, you should call AutoRunner.dispose. The AutoRunner is automatically disposed when the CoroutineScope completes.

See AutoRunner for more details.

Parameters

common

launcher The CoroutineLauncher to use.
onChange Gets called when the observables change. If you provide a handler you have to manually call run.
flowTransformer How changes should be executed/collected. Defaults to conflatedWorker.
dispatcher The CoroutineDispatcher to use. Defaults to dispatchers.main.
withLoading Tracks loading state for the (re-)computation. Defaults to launcher.loading.
observer The callback which is used to track the observables.