Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 1.38 KB

README.md

File metadata and controls

51 lines (35 loc) · 1.38 KB

Fluk

Maintainability Test Coverage

Flux architecture implementation for Kotlin

The main goals of this is implementation is to be simple, easy to use and fun to work with

Simple usage example

// Model/State
class User(val name: String)

// Actions
class SetUserAction(val user: User): Action
class ClearAction: Action
    
val store = Store<User?>(null) { state, action ->
    when (action) {
        is SetUserAction -> action.user
        is ClearAction -> null
        else -> state
    }
}

val userNameSelector = store.selector { it?.name }

store.dispatch(SetUserAction(User("John Doe")))

Assertions.assertEquals("John Doe", userNameSelector())

store.dispatch(ClearAction())

Assertions.assertEquals(null, userNameSelector())

You can find more examples at src/test/kotlin/fluk/core/usecases

Todo

  • Dispatch mechanism
  • Middlewares
  • Subscribers
  • Value watchers
  • Selectors
  • Time travel mechanism
  • Thread safe store