Reduks

General

Category
Free
Tag
Architecture
License
MIT License
Registered
Oct 9, 2017
Favorites
0
Link
https://github.com/Reduks/Reduks
See also
GreenDroid
Moviper
InterviewTest
AirCycle
Kotlin Mvp Espresso

Additional

Language
Kotlin
Version
0.1.3 (Feb 28, 2018)
Created
Aug 29, 2017
Updated
Sep 9, 2018
Owner
Reduks
Contributors
vitorprado
Bloder (bloderxd)
2
Activity
Badge
Generate
Download
Source code

Promotion

Reduks

Introduction

Reduks is an implementation of redux concept for Kotlin applications. It permits to create stores, states, actions and middlwares in an easy way. All redux concept documentation you can easily find in http://redux.js.org/

Reduks implementation

all reduks components documentation can be easily find in https://github.com/Reduks/Reduks/wiki Well, let's develop a hello world! First of all we need to create our state.


data class State(val text: String = "")

We want to do a reduks hello world, then in our action we need to return a new state with some string in there and will be "Hello World!", after that we will print this Hello World!. But first lets create our action.

sealedclassStateActions:Action<State> {

  classChangeTextTo(valtext:String) :StateActions()
}



Then we just need to create our store.

funstore() : Store<State> = reduksStore { initialState = State(""), initialReducer = { state, action ->when(action) { is ChangeTextTo -> State(action.text) else-> state }} }

That's great! We already have our reduks structure to print our hello world!

classMainClass {
  
  funmain(args:Array<String>) { 
    store().subscribe(Subscriber { state -> print(state.name) })
    store().dispatch(StateActions.ChangeTextTo("Hello World!"))
  }
}