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

autotroph

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autotroph

a simple ES5 flux library

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

autotroph

A simple Flux implementation without any build requirements or dependencies. This is easier to learn, but for real projects you should consider Redux instead!

Getting Started

This library is just an autotroph module with some properties: dispatch and other methods are based on the Flux reference dispatcher, and createStore is a helper function for creating simple stores that will receive dispatched actions.

Stores

The output of a call to autotroph.createStore() is an object that has .subscribe(), .unsubscribe(), and .getState() functions. Subscribe your render function to these stores, and then pass your action objects to autotroph.dispatch().

initialState

The first argument to autotroph.createStore() is an object with the initial values of your state variables. This object will be passed into the actionHandler along with every action that is dispatched. By default changes are saved by mutating this object, and you are responsible for adding any immutable behavior. You can assign immutable references to any property on initialState, or make initialState an array of historical state objects.

actionHandler

The second argument to autotroph.createStore() is a function that takes the current state and the action object as arguments, and returns true if the app should re-render. Check the action and either update the state or make a new immutable version in this handler. In most cases this function will return true, but you can return false to skip re-rendering.

Example

See test.html for a usage example. This file can be downloaded and run locally in most browsers with no setup.

FAQs

Package last updated on 21 Jun 2017

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