Session

interface Session<out F : Failure>

An installation or uninstallation that's being actively staged.

The session by itself is passive, so to advance it an observer is needed to appropriately handle its lifecycle by calling necessary methods. TerminalStateListener is such an observer.

Parameters

F

a type of Failure for this session, may be InstallFailure or UninstallFailure.

Inheritors

Types

Link copied to clipboard
sealed interface State<out F : Failure>

Represents the session's state.

Link copied to clipboard
fun interface StateListener<in F : Failure>

Callback interface for listening to Session state updates.

Link copied to clipboard
abstract class TerminalStateListener<in F : Failure>(session: Session<F>) : Session.StateListener<F>

A StateListener which implements onStateChanged method. This listener will call session's methods on state changes appropriately.

Properties

Link copied to clipboard
abstract val id: UUID

Returns the ID of this session.

Link copied to clipboard
abstract val isActive: Boolean

Returns true if this session is active, i.e. it is already launched and is not in terminal state.

Link copied to clipboard
abstract val isCancelled: Boolean

Returns true if this session was cancelled by invocation of cancel.

Link copied to clipboard
abstract val isCompleted: Boolean

Returns true if this session has ran to completion without cancelling.

Functions

Link copied to clipboard

Adds a StateListener to this session if it's not registered yet and appends the subscription to the subscriptions bag. The listener will be notified with current state immediately upon registering.

Link copied to clipboard
abstract fun cancel()

Cancels this session, rendering it invalid.

Link copied to clipboard
abstract fun commit(): Boolean

Commits everything that was prepared in the session. This will launch user's confirmation of installation or uninstallation.

Link copied to clipboard
abstract fun launch(): Boolean

Launches the session preparations. This includes copying needed files to temporary folder and other operations.

Link copied to clipboard

Removes the provided StateListener from this session.