lifecycle

package
v0.1.110 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CoroutineScope added in v0.1.98

type CoroutineScope interface {
	HasCoroutineScope
	Context() (context.Context, bool)
	MustContext() context.Context
	Launch(block func(ctx context.Context))
}

type FrameLifecycleAware added in v0.1.94

type FrameLifecycleAware interface {
	StartFrame()
	EndFrame()
}

type HasCoroutineScope added in v0.1.94

type HasCoroutineScope interface {
	// SetCoroutineScope provides a context that is cancelled when the remembered value is leaving the composition.
	// This is analogous to viewModelScope in Kotlin, which is a CoroutineScope.
	SetCoroutineScope(ctx context.Context)
}

HasCoroutineScope is an optional interface for ViewModels that need a managed context/scope. When a Remembered value implements this interface, it will receive a context that is cancelled when the leaving the composition.

type HasViewModelScope

type HasViewModelScope interface {
	// SetViewModelScope provides a context that is cancelled when the ViewModel is cleared.
	// This is analogous to viewModelScope in Kotlin, which is a CoroutineScope.
	SetViewModelScope(ctx context.Context)

	// OnInit is called after SetViewModelScope
	OnInit()
}

HasViewModelScope is an optional interface for ViewModels that need a managed context/scope. When a ViewModel implements this interface, it will receive a context that is cancelled when the ViewModel is cleared, enabling graceful shutdown of goroutines.

type RememberObserver

type RememberObserver interface {
	// OnForgotten is called when the object is no longer being remembered.
	// This happens when the remember call is removed from composition.
	OnForgotten()
}

RememberObserver is an interface for objects that need lifecycle callbacks when remembered in composition. This is the Go equivalent of androidx.compose.runtime.RememberObserver.

https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/RememberObserver.kt

type ViewModel

type ViewModel interface {
	// OnCleared is called when the ViewModel is no longer used and is being destroyed.
	// Use this to clean up resources such as cancelling background tasks or closing connections.
	OnCleared()
}

ViewModel is an interface that ViewModels can implement to be notified when they are cleared. In Android/Kotlin, ViewModel.onCleared() is called when the ViewModel is no longer used.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL