21 Followers
·
Follow

Simple and powerful state management solution for React and Inferno. Powered by ideas from Redux and Unstated.

Image for post
Image for post

Laco consists of three simple ideas

The first idea is the notion of a store. The store handles state and you can have multiple stores. You can create a store like so:

You can get or set a new state on your store:

The second idea is the idea of actions. An action is a function that sets a new state on a store.

The third and final idea is the idea of a Subscribe component. The Subscribe component takes an array of stores as input. The component acts like connect() for those that are familiar with Redux. The difference is that connect() is a higher order component while the Subscribe component uses render props. More on render props here.

That is the general gist of Laco. Should be simple and straightforward.

Testing

Testing example using Tape.

CounterStore.reset() takes care of some edge cases more about it here.

Debugging

Laco supports Redux Devtools Extension and React Native Debugger partially out of the box! Current supported features:

You may look into the API for correct logging with Devtools Extension and Native Debugger.

Conclusion

Laco is very lightweight (around 2kb minified) and is meant to make state management simpler which makes starting new projects more hassle free. Check out the Github repository and examples.

Written by

Making Open Source contributions ⚡️

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store