Reduks

General

Category
Free
Tag
Architecture
License
MIT License
Min SDK
0
Registered
Oct 9, 2017
Favorites
0
Link
https://github.com/Reduks/Reduks
See also
Presentation
Android MVP Starter
Redux Android Sample
ngAndroid
MVVM Life Cycle

Additional

Language
Kotlin
Version
0.1.0 (Sep 23, 2017)
Created
Aug 29, 2017
Updated
Oct 7, 2017
Owner
Reduks
Contributors
vitorprado
Bloder (bloderxd)
2
Activity
Badge
Generate
Download
Source code

Announcement

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/Reduks
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.

sealed class StateActions : Action<State> {

  class ChangeTextTo(val text: String) : StateActions()
}

Then we just need to create our store.

fun Any.store() : 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!

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

Import

Gradle
compile 'com.reduks:reduks:0.1.2'
Maven
<dependency>
  <groupId>com.reduks</groupId>
  <artifactId>reduks</artifactId>
  <version>0.1.2</version>
  <type>pom</type>
</dependency>
Ivy
<dependency org='com.reduks' name='reduks' rev='0.1.2'>
  <artifact name='reduks' ext='pom' ></artifact>
</dependency>

Inspiration

Reduks was inspired in some other tools, and we'd like to thank all of them

License

MIT License

Copyright (c) 2017 Reduks

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.