PaywallViewCache

class PaywallViewCache(val appCtx: Context, val viewStorage: ViewStorage, val activityProvider: ActivityProvider, val deviceHelper: DeviceHelper, @ColorRes loadingColor: Int? = null, val actor: SequentialActor<PaywallCacheContext, PaywallCacheState>) : PaywallCacheContext(source)

Cache for paywall, loading, and shimmer views.

State is owned by a SequentialActor — every mutation is enqueued through a single FIFO consumer, so state.value always reflects the latest committed data and there are no races between save/get, remove/save, or concurrent acquire calls. ViewStorage is kept as a write-through mirror because external readers (SuperwallPaywallActivity, DebugView) read it directly. Every write must go through this cache (save, storeView, removeView, ...) so the two never disagree about which keys exist.

Constructors

Link copied to clipboard
constructor(appCtx: Context, viewStorage: ViewStorage, activityProvider: ActivityProvider, deviceHelper: DeviceHelper, @ColorRes loadingColor: Int? = null, actor: SequentialActor<PaywallCacheContext, PaywallCacheState>)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val appCtx: Context
Link copied to clipboard
open val ctx: Context
Link copied to clipboard
open override val deviceHelper: DeviceHelper
Link copied to clipboard
Link copied to clipboard
open override val scope: CoroutineScope
Link copied to clipboard
open override val state: StateFlow<PaywallCacheState>

Delegate state reads to the actor.

Link copied to clipboard
open override val viewStorage: ViewStorage

Functions

Link copied to clipboard

Synchronous because PaywallView.present is non-suspend.

Link copied to clipboard
Link copied to clipboard

Fire-and-forget dispatch of a sub-action on this context's actor.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open suspend fun immediate(action: TypedAction<PaywallCacheContext>)
Link copied to clipboard
Link copied to clipboard
suspend fun removeAll()
Link copied to clipboard
suspend fun removePaywallView(identifier: PaywallIdentifier)
Link copied to clipboard
fun removeView(key: String)

Synchronous counterpart of storeView.

Link copied to clipboard
suspend fun save(paywallView: PaywallView, identifier: PaywallIdentifier)
Link copied to clipboard
open fun sideEffect(what: suspend () -> Unit)
Link copied to clipboard
fun storeView(key: String, view: View)

Stores a view under an arbitrary key (activity launch and restore keys, debug views). Synchronous because callers hand key to an Activity that reads ViewStorage as soon as it is created. Both writes are atomic map operations, so no queued action is needed for consistency.

Link copied to clipboard
open override fun update(reducer: Reducer<PaywallCacheState>)

Apply a state reducer inline.