Skip to content

Commit a8c2962

Browse files
author
Patrick Jackson
committed
remove extension function in combineReducers. Update comments
1 parent 4b0ddad commit a8c2962

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed
Lines changed: 13 additions & 0 deletions
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+
}
Lines changed: 3 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)