Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

acta

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acta

Super light and dead simple state manager and event dispatcher for react.

  • 3.0.15
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
46K
decreased by-6.93%
Maintainers
1
Weekly downloads
 
Created
Source


Acta logo


Super light dead simple state manager and event dispatcher for React. May you never ask yourself again "where are those props coming from?". Get to the quick start. Or watch the 2 minutes video.

short tutorial thumbnail


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

Keywords

FAQs

Package last updated on 26 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc