0.20.0 • Published 4 years ago

@re-frame/core v0.20.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

re-frame

Build Status Bundle Size

JavaScript port of the popular ClojureScript library for pragmatic, flux-like state management. I highly recommend checking out re-frame's original documentation to learn about its philosophy, patterns, and terminology. All design credit goes to the original authors — thank you for the inspiration.

Why re-frame?

Re-frame helps make state management predictable, testable, and pragmatic. From a high-level, re-frame is flux-like with events and event handlers, which are similar to redux's actions and reducers. Compared to redux, re-frame is more feature complete out of the box, with built-in interceptors and subscriptions. You'll find that you can be productive without needing to reach for third-party middleware.

Installation

# npm users
npm install --save @re-frame/core

# yarn users
yarn add @re-frame/core

Usage

import {createStore} from '@re-frame/core'

// you can optionally provide an initial state as the first argument
const store = createStore({ count: 0 })

// register event handlers with your store
store.registerEventDB('increment', db => ({ ...db, count: count + 1 }))
store.registerEventDB('add', (db, event) => ({ ...db, count: count + event[1] }))

// dispatch events to your store
store.dispatch(['increment']) // store state = { count: 1 }
store.dispatch(['increment']) // store state = { count: 2 }

// you can also supply a payload with the event
store.dispatch(['add', 3])    // store state = { count: 5 }
0.20.0

4 years ago

0.19.0

4 years ago

0.4.0

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.1.0-alpha.2

5 years ago

0.1.0-alpha.1

5 years ago

0.1.0-alpha.0

5 years ago