diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-10-17 21:58:34 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-10-17 21:58:34 +0200 |
commit | 736b80835f67c9c34657074ebcfbe0752bef1c18 (patch) | |
tree | 82d1e18a9ec07692dfe5dd31f470b842a9950a89 /src/main/kotlin/pl/treksoft/kvision/state | |
parent | 53b325d52208bfd44ba6a524ce3dda5379aed699 (diff) | |
download | kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.tar.gz kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.tar.bz2 kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.zip |
Move DSL builder functions out of the companion objects (#93)
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/state')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/state/StateBinding.kt | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/state/StateBinding.kt b/src/main/kotlin/pl/treksoft/kvision/state/StateBinding.kt index adb7d3be..20cb2d8e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/state/StateBinding.kt +++ b/src/main/kotlin/pl/treksoft/kvision/state/StateBinding.kt @@ -49,7 +49,7 @@ class StateBinding<S : Any, CONT : Container, CONTENT>( } } - private fun setUpdateState(updateState: (S, CONTENT) -> Unit) { + internal fun setUpdateState(updateState: (S, CONTENT) -> Unit) { this.updateState = updateState } @@ -57,32 +57,30 @@ class StateBinding<S : Any, CONT : Container, CONTENT>( unsubscribe() super.dispose() } +} - companion object { - /** - * DSL builder extension function. - * - * It takes the same parameters as the constructor of the built component. - */ - fun <S : Any, CONT : Container> CONT.stateBinding( - observableState: ObservableState<S>, - factory: (CONT.(S) -> Unit) - ): StateBinding<S, CONT, Unit> { - return StateBinding(observableState, this, factory) - } +/** + * DSL builder extension function. + * + * It takes the same parameters as the constructor of the built component. + */ +fun <S : Any, CONT : Container> CONT.stateBinding( + observableState: ObservableState<S>, + factory: (CONT.(S) -> Unit) +): StateBinding<S, CONT, Unit> { + return StateBinding(observableState, this, factory) +} - /** - * DSL builder extension function for updateable redux content. - * - * It takes the same parameters as the constructor of the built component. - */ - fun <S : Any, CONT : Container, CONTENT> CONT.stateUpdate( - observableState: ObservableState<S>, - factory: (CONT.(S) -> CONTENT) - ): Updateable<S, CONTENT> { - return Updateable(StateBinding(observableState, this, factory)::setUpdateState) - } - } +/** + * DSL builder extension function for updateable redux content. + * + * It takes the same parameters as the constructor of the built component. + */ +fun <S : Any, CONT : Container, CONTENT> CONT.stateUpdate( + observableState: ObservableState<S>, + factory: (CONT.(S) -> CONTENT) +): Updateable<S, CONTENT> { + return Updateable(StateBinding(observableState, this, factory)::setUpdateState) } /** |