Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Coordinate React components' states with event sourcing.

License

Notifications You must be signed in to change notification settings

pinyin/flock-js

Repository files navigation

flock-js

Build Status

Coordinate React components' states with event sourcing.

Inspired by Flux, Redux and Redux Saga.

Usage

In your React component, replace all useReducer with useStoreReducer:

import { useContextStoreReducer, StoreContext } from 'flock-js'
const store = createStore()

// then update your code
// from
const [state, dispatch] = useReducer(reducer, initialState)
// to
const [state, dispatch] = useStoreReducer(store, reducer, (actions) => /* compute initialState from actions */)

Components will then be able to consume each other's actions.

See test files in src/react for more information.

More functions on the way.

About

Coordinate React components' states with event sourcing.

Resources

License

Stars

Watchers

Forks

Packages

No packages published