beyondeye / reduks Goto Github PK
View Code? Open in Web Editor NEWA "batteries included" port of Reduxjs for Kotlin+Android
License: Apache License 2.0
A "batteries included" port of Reduxjs for Kotlin+Android
License: Apache License 2.0
Currently the reduks-android module does not have any real android dep, just an interface called interface ReduksActivity<S>
that does not actually depends on android activity.
What about reintegrating ReduksActivity<S>
in core and creating instead two modules with real dependency on android, one for rx (RxReduksActivity
) and one for kovenant (KovenantReduksActivity
).
Or perhaps explore a different a way to do this: the need of having a base activity class for using reduks is an ugly design pattern.
It would be useful to have something equivalent to https://github.com/JakeWharton/RxBinding for reduks
Based on main redux documentation, listener function signature is subscribe(listener: () => void): Unsubscribe;
I propose we should match that in other words, we remove the state argument from StoreSubscriber
From
public interface StoreSubscriber<S> {
void onStateChange(S state);
}
To
public interface StoreSubscriber<S> {
void onStateChange();
}
Then it is responsibility of the call site to call store.state
in order to get current state value.
Hello, I could not find a better way to contact you. Sorry :/
Because you worked on Redux for the JVM, I've been thinking you may be interested in joining the collective we are starting on that subject. We would like to explore it more and see how far we can go.
If you want to join, please follow the link ->
https://docs.google.com/document/d/13jdWEI1Jqs5GHO0pG6qMloOEQdph9If-tj9P1I3VHDA/edit?usp=sharing
Best
After adding support for modules, method count in reduks core has increased to significantly (the module package has now 524 method). Need to find a way to reduce it. Using data classes for module def was a bad idea probably, because it adds tons of methods I don't actually need. See attached full list of methods
core_method_list.txt
For representing the state more efficiently, immutable collections are very useful. I started working with the PCollections lib, that is also used in the current proposal for immutable collections for kotlin.
Hello @beyondeye, I looked at how it could be implemented by your Store and I think it would be required subtle changes. Though, it should be easier with the other non-core modules.
Should I try to implement it on some modules? If yes, do you have a preference ?
https://github.com/jvm-redux/jvm-redux-api/
Cheers !
Hi,
I am currently learning to implement this architecture in a small Android app but I am not sure where I should create and keep my Store? How would I handle saving/restoring the state if I do it in a application wide Singleton? Or would it be a good idea to use the Android Arch. Components ViewModel Class and create a store for every activity?
Thanks for your input!
Would you please mind creating some examples using Reduks, e.g. a to-do list?
Thanks so much for this library!
How do you feel about having a phantom type for all action? I personally feel that the usage of Object for an action is too broad. This could be a simple and empty interface that provide a loose frame for all user action to follow.
interface Action
Another thing on my mind right now is having a Standard action for Reduks. It is pretty much similar to "upstream" redux.js counterpart where they define a recommended-but-not-mandatory structure for Action. You could look at here for the reference, flux-standard-action. This could be something similar to this
interface StandardAction {
val payload: Any?
val error: Boolean
val meta: Any?
}
What do you think?
Inspiration from https://github.com/tappleby/redux-batched-subscribe
see discussion in issue #8
Reduks can be potentially used for developing applications for both android and web. Reduks core already does not depend from any java library, but there are still some interfaces kept in Java for leveraging automatic SAM conversion.
It should be easy substitute them with pure kotlin code
withField
requires a non-null value:
fun<I1 : Any> withField(fn: S.() -> I1) = SelectorForP2<S, I0, I1>(si0, InputField(fn))
, where I1: Any
Say we have a state like:
data class MyState(val apiResult: ApiResult?)
Writing SelectorBuilder<MyState>().withField { apiResult }
won't compile because ApiResult? is not a subtype of Any
Is there another way to circumvent this?
The event bus pattern is very useful in Android for passing data between activities and fragments, instead of using awful callbacks like OnActivityResult. Reduks is kind of similar to in architecture to an event bus but not exactly the same. When trying to use Reduks to pass data (dispatch) to subscribers, need to add a lot of boilerplate to handle the intermediate processing by reducers to the store before the data reach subscribers. I should probably write a store enhancer to reduce the boilerplate.
Can I configure .subscribe to be only exectued on a specific thread?
In my effort to improve support for rx and provide better middleware for async action, I should implement
epics and saga.
For epics see for reference https://redux-observable.js.org/docs/basics/Epics.html
There is also an implementation in kotlin for rxjava by Michael Pardo here: https://github.com/pardom/redux-observable-kotlin
A very similar middleware that is independent from rx is redux-saga
http://yelouafi.github.io/redux-saga/
I could implement both, merging interfaces, for having the same functionality both when using rxjava or something else (kotlin coroutines/ kovenant promises)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.