-
public final class RememberRiveWorkerKt
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringRIVE_WORKER_TAG
-
Method Summary
Modifier and Type Method Description final static CommandQueuerememberRiveWorker(Boolean autoPoll, Boolean tracingEnabled, RenderBackend renderBackend)A RiveWorker is the worker that runs Rive in a thread. final static CommandQueuerememberRiveWorkerOrNull(MutableState<Throwable> errorState, Boolean autoPoll, Boolean tracingEnabled, RenderBackend renderBackend)A nullable variant of rememberRiveWorker that returns null if the Rive worker cannot be created. -
-
Method Detail
-
rememberRiveWorker
@Composable() final static CommandQueue rememberRiveWorker(Boolean autoPoll, Boolean tracingEnabled, RenderBackend renderBackend)
A RiveWorker is the worker that runs Rive in a thread. It holds all of the state, including assets (images, audio, and fonts), RiveFiles, artboards, state machines, and view model instances.
The lifetime of the Rive worker reference created by this composable is managed by this composable. It releases that reference when it falls out of scope. The worker fully disposes once any other Rive resources that acquired it, such as files, assets, or surfaces, are also closed.
A Rive worker needs to be polled to receive messages from the command server. This composable creates a poll loop that runs while the Lifecycle is in the Lifecycle.State.RESUMED state. The poll rate is once per frame, which is typically 60 FPS.
This function throws a RuntimeException if the Rive worker cannot be created. If you want to handle failure gracefully, use rememberRiveWorkerOrNull instead.
- Parameters:
autoPoll- Whether to automatically poll the worker while lifecycle is RESUMED.tracingEnabled- Whether native draw/advance tracing is enabled for the worker.renderBackend- Preferred render backend.
-
rememberRiveWorkerOrNull
@Composable() final static CommandQueue rememberRiveWorkerOrNull(MutableState<Throwable> errorState, Boolean autoPoll, Boolean tracingEnabled, RenderBackend renderBackend)
A nullable variant of rememberRiveWorker that returns null if the Rive worker cannot be created.
Use this variant if you want to handle the failure of Rive worker creation gracefully, which may be desirable in production.
- Parameters:
errorState- A mutable state that holds the error if the Rive worker creation fails.autoPoll- Whether to automatically poll the worker while lifecycle is RESUMED.tracingEnabled- Whether native draw/advance tracing is enabled for the worker.renderBackend- Preferred render backend.
-
-
-
-