TWSManager

interface TWSManager

A manager interface for handling snippets, their properties, and lifecycle events.

Instances of TWSManager should be created using TWSFactory.

Example Usage

val manager = TWSFactory.get(context)
val projectSnippets = manager.snippets.collectAsStateWithLifecycle(null).value
// Use projectSnippets with TWSView or process them as needed

Properties

Link copied to clipboard
abstract val snippets: Flow<TWSOutcome<List<TWSSnippet>>>

A flow that combines remote snippets with local properties to keep the data in sync and up-to-date. Use collectAsStateWithLifecycle to automatically start and stop data collection based on the lifecycle.

Functions

Link copied to clipboard
abstract fun forceRefresh()

Forces a refresh of the snippets by reloading them from the remote source. Updates are emitted in snippets flow to all active collectors and cached for future use.

Link copied to clipboard
abstract fun logEvent(event: String)

Logs a user-defined event and fetches campaign-based snippets from the backend. If the backend returns any matching campaign snippets, all are displayed immediately using a popup UI.

Link copied to clipboard
abstract fun register()

Creates a connection to a backend service and prepares snippets, note that this MUST be called before manager can actually be used, otherwise connection to a backend service will not be established.

Link copied to clipboard
abstract fun set(id: String, localProps: Map<String, Any>)

Updates or adds local properties for a specific snippet. These properties are applied to the snippet for all active collectors.

Link copied to clipboard
abstract fun snippets(): Flow<List<TWSSnippet>?>

Retrieves the list of snippets as a flow of data only. Use collectAsStateWithLifecycle to automatically start and stop data collection based on the lifecycle.