Skip to content

Commit f927da6

Browse files
authored
Merge pull request #3 from reduxkotlin/cleanup
remove extension function in combineReducers. Update comments
2 parents 4b0ddad + a8c2962 commit f927da6

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.reduxkotlin
2+
3+
fun combineReducers(vararg reducers: Reducer): Reducer =
4+
{ state, action ->
5+
reducers.fold(state, { s, reducer -> reducer(s, action) })
6+
}
7+
8+
/**
9+
* combine two reducer with + operator
10+
*/
11+
operator fun Reducer.plus(other: Reducer): Reducer = { s, a ->
12+
other(this(s, a), a)
13+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.reduxkotlin
22

3+
/**
4+
* Composes a list of single argument functions from right to left.
5+
*/
36
fun <T> compose(functions: List<(T) -> T>): (T) -> T =
47
{ x -> functions.foldRight(x, { f, composed -> f(composed) })
58
}

lib/src/commonMain/kotlin/org/reduxkotlin/Definitions.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ typealias StoreSubscription = () -> Unit
1212
typealias Dispatcher = (Any) -> Any
1313
typealias StoreCreator = (reducer: Reducer, initialState: Any, s: StoreEnhancerWrapper?) -> Store
1414
/**
15-
* get a store creator and return a new enhanced one
15+
* Take a store creator and return a new enhanced one
1616
* see https://github.com/reactjs/redux/blob/master/docs/Glossary.md#store-enhancer
1717
*/
1818
typealias StoreEnhancer = (next: StoreCreator) -> StoreCreator
@@ -28,7 +28,7 @@ class StoreEnhancerWrapper(val storeEnhancer2: StoreEnhancer) : StoreEnhancer {
2828
}
2929

3030
/**
31-
* see also https://github.com/reactjs/redux/blob/master/docs/Glossary.md#middleware
31+
* https://github.com/reactjs/redux/blob/master/docs/Glossary.md#middleware
3232
*/
3333
typealias Middleware = (store: Store) -> (next: Dispatcher) -> (action: Any) -> Any
3434

lib/src/commonMain/kotlin/org/reduxkotlin/combineReducers.kt

-20
This file was deleted.

0 commit comments

Comments
 (0)