question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow to use any arbitrary source of data for `stateBinding`

See original GitHub issue

Hi,

First of all, thanks for the awesome work! This framework looks very nice!

I want to propose an improvement of the stateBinding feature. Currently, it is tighly bound to ReduxStore. But the only really important thing is that it should observe changing state, and update the component.

So it would be nice if there was an alternative such as:

fun <S, CONT : Container> CONT.stateBinding(states: Flow<S>, factory: CONT.(S) -> Unit)

It would then allow to use any state management technology. Not only redux.

And the redux version could become an overload such as:

fun <S : Any, CONT : Container> CONT.stateBinding(store: ReduxStore<S>, factory: CONT.(S) -> Unit) =
    stateBinding(store.asFlow(), factory)
   
fun <S : Any> ReduxStore<out S, *>.asFlow(): Flow<S> = channelFlow {
  val unsubscribe = subscribe { state -> offer(state) }
  awaitClose { unsubscribe() }
}.conflate()

The thing is, despite I like very much the philosophy behind redux and that state binding, I don’t like using Redux directly since it forces me to make my in-memory state serializable (which is awkward and limiting). And creating state management based on immutable state and pure reducer in Kotlin is far too easy to justify the complexity and limitation of using Redux.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rjaroscommented, Oct 13, 2019

Changed it to:

interface ObservableState<S> {
    fun subscribe(observer: (S) -> Unit): () -> Unit
}

The return value is an unsubscribe function, just like with the redux store.

0reactions
rjaroscommented, Oct 13, 2019

Until now unsubscribing was not even implemented in StateBinding class. I’ll take a look at this again 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redux states - do they need to be serializable? #58 - GitHub
Is there any specific reason why KVision's redux module should require ... Allow to use any arbitrary source of data for stateBinding #91....
Read more >
Multicast Command Reference for Cisco CRS Series Routers
To enable accounting for multicast routing, use the accounting ... an arbitrary interface is selected as the active MHost default.
Read more >
Replica-Exchange and Standard State Binding Free Energies ...
Using eq 5, the titration data for all the BPTI simulations were used to calculate binding free energies for each RE frequency. As...
Read more >
Binding syntax - Angular
You use data binding to specify things such as the source of an image, the state of a button, or data for a...
Read more >
Standalone and User-Friendly GUIs for Fast 1D NMR ... - NCBI
The generated data can contain arbitrary noise and any number of points as requested by the user. The results will be automatically plotted, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found