Skip to content

Simple Flux architecture implementation for Kolin

Notifications You must be signed in to change notification settings

Brunomachadob/fluk

Repository files navigation

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

About

Simple Flux architecture implementation for Kolin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages