3.0.15 • Published 2 years ago

acta v3.0.15

Weekly downloads
38,981
License
MIT
Repository
github
Last release
2 years ago

badgen minzip Coverage Status codacy code quality badgen typescript badgen types included badgen mit licence badgen npm version code style: prettier

  • Explicit over implicit.
  • Minimal dataflow: the component subscribing is the one using the data.
  • Zero setups, no provider or observable system.

Acta is providing

  • A unique global store with keys indexed values.
  • A one line straight forward way of subscribing to the application state in a class component Acta.subscribeState('appStateKey', 'localStateKey');.
  • A hook for functional components const valueFromActa = Acta.useActaState('appStateKey'); that share states with class components.
  • A simple way of setting / getting the state Acta.setState({appStateKey: value}).
  • A one line straight forward way of subscribing application events in a class component Acta.subscribeState('appEventKey', handler);.
  • A hook for functional components Acta.useActaEvent('appEventKey', handler); that share events. with class components.
  • A simple way of dispatching an event Acta.dispatchEvent('appEventKey', value).
  • Optional local/session storage persistence.
  • Shared states and events between tabs and windows.
  • Great performances since the store contains references to the callbacks instead of having to iterate on every reducer and stop only when it finds the corresponding ones.
  • Self-cleaning methods unsubscribing to states and events.
  • An exposed global object that you can call from anywhere without having to set up and pass providers, wrappers, or decorators.

In Acta states, you can store string, numbers, and booleans; in object literals and in arrays. Since all values stored have to be compatible with the local storage Maps, Sets or functions won’t work.

You don't need tooling to debug Acta. Just type Acta in your browser console and see the object and the internals.

Why another state manager?

React ecosystem already has excellent state managers. Redux and MobX are great tools. But teams tend to make a mess of their codebase with overcomplicated state management patterns because they have seen it work for big applications and online tutorials encouraging premature scaling optimizations.

Maintainability is the ability to make changes with confidence. If you cannot understand your dataflow instantly today and describe it in a simple sentence, it means that three months from now you will be lost in the layers of abstraction that you just created and that any modification will be a nightmare.

If an action calls a dispatcher to push updated data in a middleware that will look into a bunch of reducers to find the one that will transform the updated data to push them into a provider that will trigger a mapping from the transformed updated data into properties in a higher-order function that wraps the parent of the component where the data will be displayed... Well, congratulations, you made the life of the next guy hell. And this is not a caricature, some applications have way more complicated dataflow. Sometimes it's required; but if I bet that it's not your case, I'll be right 99.9% of the time.

The goal of Acta is to make you forget about reducers, observers, map to props, providers, HOCs... Components are explicitly responsible for subscribing to the state or event. You can call for a complex data treatment inside the component. You can have actions that will be triggered. But the incoming data flow should be the most direct possible.

forthebadge

3.0.14

2 years ago

3.0.15

2 years ago

3.0.12

4 years ago

3.0.13

4 years ago

3.0.11

4 years ago

3.0.10

4 years ago

3.0.9

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.4

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.2.0

5 years ago

2.1.2

5 years ago

2.1.3

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago