Skip to content
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

replace BaseComponent with a functional connection API #12

Closed
Ma27 opened this issue Apr 18, 2016 · 2 comments · Fixed by #19
Closed

replace BaseComponent with a functional connection API #12

Ma27 opened this issue Apr 18, 2016 · 2 comments · Fixed by #19

Comments

@Ma27
Copy link
Contributor

Ma27 commented Apr 18, 2016

Description of the issue

the BaseComponent is a simple hack in the spec of this implementation which shouldn't exist as public API classes should be avoided (https://medium.com/@dan_abramov/how-to-use-classes-and-sleep-at-night-9af8de78ccb4#.jm9evg8ba) and the BaseComponent is something that should be removed.
Instead a lightweight connection library could be created:

// add.
componentDidMount() {
  connector(storeObj).useWith(this.handler);
}

// remove.
componentWillUnmount() {
  connector(storeObj).unsubscribe(this.handler);
}

What's with the BaseStore

the big issue of the components is the hacky OO approach: we declare properties in the constructor of the component, use super calls in our lifecycle hooks to make the subscription work build a even bigger component structure which is harder to understand.

The BaseStore utilizes the approach of creating a simple and dumb data object which flushes changes in its state to the view. Stores should be instantiated as they're just simple objects and the instance should be passed to module.exports and not the class. Therefore the BaseStore is not a big design issue, but the BaseComponent is.

@Ma27 Ma27 self-assigned this Apr 18, 2016
@Ma27 Ma27 added this to the 1.0.2 milestone Apr 18, 2016
@Ma27
Copy link
Contributor Author

Ma27 commented Apr 18, 2016

@benbieler what do you think??

@Ma27
Copy link
Contributor Author

Ma27 commented Apr 18, 2016

another improvement would be that we can resolve the peer dependency to react

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant