Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
io.github.copper-leaf:ballast-core-iosarm64
Advanced tools
Opinionated Application State Management framework for Kotlin Multiplatform
Opinionated Application State Management framework for Kotlin Multiplatform
object TodosContract {
data class State(
val loading: Boolean = false,
val todos: List<String> = emptyList(),
)
sealed interface Inputs {
data object FetchSavedTodos : Inputs
data class AddTodo(val text: String) : Inputs
data class RemoveTodo(val text: String) : Inputs
}
}
class TodosInputHandler : InputHandler<Inputs, Events, State> {
override suspend fun InputHandlerScope<Inputs, Events, State>.handleInput(
input: TodosContract.Inputs
) = when (input) {
is FetchSavedTodos -> {
updateState { it.copy(loading = true) }
val todos = todosApi.fetchTodos()
updateState { it.copy(loading = false, todos = todos) }
}
is AddTodo -> {
updateState { it.copy(todos = it.todos + input.text) }
}
is RemoveTodo -> {
updateState { it.copy(todos = it.todos - input.text) }
}
}
}
@Composable
fun App() {
val coroutineScope = rememberCoroutineScope()
val vm = remember(coroutineScope) { TodosViewModel(coroutineScope) }
val vmState by vm.observeStates().collectAsState()
LaunchedEffect(vm) {
vm.send(TodosContract.FetchSavedTodos)
}
TodosList(vmState) { vm.trySend(it) }
}
@Composable
fun TodosList(
vmState: TodosContract.State,
postInput: (TodosContract.Inputs)->Unit,
) {
// ...
}
Ballast was intentionally designed to not be tied directly to any particular platform or UI toolkit. In fact, while most Kotlin MVI libraries were initially developed for Android and show many artifacts of that initial base, Ballast started as a State Management solution for Compose Desktop.
Because Ballast was initially designed entirely in a non-Android context, it should work in any Kotlin target or platform as long as it works with Coroutines and Flows. However, the following targets are officially supported, in that they have been tested and are known to work there, or have specific features for that platform
repositories {
mavenCentral()
// SNAPSHOT builds are available as well at the MavenCentral Snapshots repository
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots")
}
// for plain JVM or Android projects
dependencies {
implementation("io.github.copper-leaf:ballast-core:{{site.version}}")
implementation("io.github.copper-leaf:ballast-repository:{{site.version}}")
implementation("io.github.copper-leaf:ballast-saved-state:{{site.version}}")
implementation("io.github.copper-leaf:ballast-sync:{{site.version}}")
implementation("io.github.copper-leaf:ballast-undo:{{site.version}}")
implementation("io.github.copper-leaf:ballast-navigation:{{site.version}}")
implementation("io.github.copper-leaf:ballast-schedules:{{site.version}}")
implementation("io.github.copper-leaf:ballast-crash-reporting:{{site.version}}")
implementation("io.github.copper-leaf:ballast-analytics:{{site.version}}")
implementation("io.github.copper-leaf:ballast-debugger-client:{{site.version}}")
testImplementation("io.github.copper-leaf:ballast-test:{{site.version}}")
}
// for multiplatform projects
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.copper-leaf:ballast-core:{{site.version}}")
implementation("io.github.copper-leaf:ballast-repository:{{site.version}}")
implementation("io.github.copper-leaf:ballast-saved-state:{{site.version}}")
implementation("io.github.copper-leaf:ballast-sync:{{site.version}}")
implementation("io.github.copper-leaf:ballast-undo:{{site.version}}")
implementation("io.github.copper-leaf:ballast-navigation:{{site.version}}")
implementation("io.github.copper-leaf:ballast-schedules:{{site.version}}")
implementation("io.github.copper-leaf:ballast-crash-reporting:{{site.version}}")
implementation("io.github.copper-leaf:ballast-analytics:{{site.version}}")
implementation("io.github.copper-leaf:ballast-debugger-client:{{site.version}}")=
}
}
val commonTest by getting {
dependencies {
implementation("io.github.copper-leaf:ballast-test:{{site.version}}")
}
}
val androidMain by getting {
dependencies {
implementation("io.github.copper-leaf:ballast-firebase-crashlytics:{{site.version}}")
implementation("io.github.copper-leaf:ballast-firebase-analytics:{{site.version}}")
}
}
}
}
See the website for detailed documentation and usage instructions.
Join us at https://kotlinlang.slack.com in the #ballast
channel for support, or to show off what you're building with Ballast!
https://kotlinlang.slack.com/archives/C03GTEJ9Y3E
Ballast is licensed under the BSD 3-Clause License, see LICENSE.md.
Ballast is not new, it was built upon years of experience building UI applications in Android and observing the direction UI programming has gone in the past few years. The MVI model has proven itself to be robust to a wide array of applications, and there are different implementations of the pattern that focus on different aspects of the pattern.
The following are some of the main libraries I drew inspiration from while using Ballast. If Ballast does not fit your project's needs, maybe one of these will suit you better. See the feature comparison for a better breakdown of the specific features of these libraries, to demonstrate the similarities and differences between them.
FAQs
Opinionated Application State Management framework for Kotlin Multiplatform
We found that io.github.copper-leaf:ballast-core-iosarm64 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.