-
-
Notifications
You must be signed in to change notification settings - Fork 386
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
Refactor data store on frontend #95
Comments
Redux is not so bloated in fact. But it isn't limited as just state store. It could bring much more. Devtools support will help better create mental image of the app. It opens a lot of render optimizations for free. It also helps to better decouple components #96 . |
It's true for SPA, but we create a widget and we need to try keep them as small as possible. I understand cons and pros of Redux, but IDK why we need it here. Do you have any ideas? Why we need redux-like store? |
Also don't forget about bindings for redux — preact-redux: So, these two have size which equals to whole remark42 package (except polyfills: #102). |
It still just 1/4 of babel-polyfill. :) I will return to this issue right after #102 |
It just too hard to pass-through state managed in few root components to multiple nested childs by props. It's hard to manage and hard to build a mental image of the app in the head. Redux enables us the way to pass data directly to components and track what is happening in the app.
What about bundle sizes. #102 already shrinks a lot of space in main remark.js bundle. We can go further and split the vendor bundle to contain preact, axios, redux and preact-redux. It will then remove duplication in existing bundles. So in sum we will be still in the win. |
A bit of stats with minified uncompressed sizes: current:
with #102
with #102 and redux + preact-redux
with #102 and redux + preact-redux and vendor bundle
|
@igoradamenko what about a little PoC with redux before making final decision? |
@Guria, let's do it. I am definitely not against Redux at all. And I like your point about getting more contributors and clearer components structure. I don't like Redux everywhere in my projects, but there I can control everything. Remark42 is an OSS, so we really need to think about contributors and easy way for them here. Let's try to use Redux, if you want to. |
Ok, I'll take this task then |
Everything is moved to redux, consider it fixed. |
On frontend we use Store class which is defined here:
https://github.com/umputun/remark/blob/master/web/app/common/store.js
It's a regular singleton, which implements some logic for getting / setting data and adds availability to listen changes. I didn't want to use something like Redux, because we used Preact and it would be strange to bloat our frontend with a huge library because of a simple store abstraction.
But I'm pretty sure that it's possible to rewrite this implementation to make it clearer. I think we should try to do it.
The text was updated successfully, but these errors were encountered: