Kotlin-flux: Android-Kotlin 助焊剂库的使用指南
Kotlin-flux 是一个用于 Android-Kotlin 的助焊剂库。以下是使用该库的步骤:1. 创建 Action 子类:定义一个名为 UpdateCountAction 的 Action 子类。kotlin class UpdateCountAction(val count: String) : Action() {}
2. 创建 Store 子类:定义一个名为 Counter 的 Store 子类,并订阅操作以更新值。在值更改后,调用 notifyChanged() 方法通知订阅者更新。kotlin object Counter : Store() { var count: Int = 0 private set(value) { field = value notifyChanged() } init { // 订阅 action subscribeAction(UpdateCountAction::class.java) } }
12.82MB
文件大小:
评论区