New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redux states - do they need to be serializable? #58
Comments
I've just created a redux implementation that doesn't require data classes to be serializable, it is based on this webpage: https://jayrambhia.com/blog/kotlin-redux-architecture
@rjaros I can replace the existing kvision redux module with this one if you think its appropriate, the usage can be made to be similar to the existing |
I also have trouble with the |
I was able to get |
First the Redux case. It's not that simple. The original Redux (redux.js.org) is quite sophisticated piece of software. It's extendable with addons and middleware and Regarding the serializable requirement - the kotlin-redux project I'm using has some limitations with Kotlin Lists. I've decided that support for Lists is more important, so my What can be done:
|
Regarding |
Without serializable data model, you just have to use native JS Tabulator functionality - you have to work with native JS data and not Kotlin data. |
And this time I don't really see any workarounds. Without |
Well either I'm missing something, or we really don't need serializable (for Redux at least), I've just rewritten the redux implementation in KVision to remove serialization and it works just fine with my complicated State and Reducers. I have multiple classes (e.g. ObjectID from MongoDB) without custom serializers that can be called from the state inside the subscribe function. I've also tested this simple example given in the guide for thunk middleware:
I think this can be explained because the JetBrains redux wrapper that KVision depends on does not appear to restrict classes to being serializable, the restriction seems to come directly from the KVision code. As for the limitation with lists, could we perhaps find a way around this, perhaps using Arrays instead of lists like they suggest? |
Am I missing something? I can upload the new code if you want to investigate it further |
The description of the restriction actually mentions using the |
yes I hope so, removing serialization would simplify a lot of my code, currently I have to have two classes, one that operates with KStitch that doesn't require serialization and one that operates with KVision that does. I will upload the replacement code shortly for you to check out. |
here are the modified files in redux main: |
I can put this in a pull request alongside the tabulator update, I've found the same thing applicable to the |
The redux module is already fixed in my source tree. I've modified some tests to check if lists are working and it seems they do. Thx for this enhancement. |
ok no problems, I could have submitted a PR but that's okay. I will send through a PR for the Tabulator update. |
But I'm still not convinced about the Tabulator - have you modified the Tabulator class and all the options classes by removing the whole |
I've just submitted a PR, perhaps there are some obscure options I have not considered, but all of the options I am using seem pretty obscure already (FormatterComponentFunction, ObservableLists). Let me know if you spot anything that is pretty obviously in need of a serializer 👍 Edit: the code is combined with the Pace module PR, I still haven't found a way to have two separate PRs from the same fork |
I had some issues with custom editors, but I've managed to make them work. I'm still not sure this change is 100% safe (it will probably work correctly with data classes only), but I think it's worth trying. |
that's good news, if there is something fundamental about the serializable code we can always change it back but I don't think so. I always thought Kotlin data classes got compiled into named JavaScript objects. It appears that way if you run the below code:
I don't think there is ever a need to serialize Kotlin classes to work with external JavaScript libraries. Anyway, I think removing the serializable requirement makes it less restrictive overall 👍 |
Is there any specific reason why KVision's redux module should require serializable data classes?
I'm running into a problem with a custom class of
ObjectID
from MongoDB. I've written a custom serializer for my class:but when I try to run it in the browser, I get
Can't locate argument-less serializer for class null
even though none of my variables in the redux state are nullable.Is it possible to remove the requirement for it to be serializable? Unless there is a specific reason why it needs to be.
The text was updated successfully, but these errors were encountered: