0.7.0 • Published 3 years ago

retreon v0.7.0

Weekly downloads
12
License
MIT
Repository
github
Last release
3 years ago


Purpose

Redux is a phenomenally powerful tool, and it can be a true joy to work with. But it takes time to find good tooling and develop healthy patterns.

Retreon aims to provide good patterns and strong types out of the box, including tools for async actions and error handling. Retreon is FSA compliant.

Here's a taste:

// actions.ts
const fetchResource = createAction.async('fetch-resource', async (id: number) => {
  const response = await fetch(`/resources/${id}`)
  return response.json()
})
// reducer.ts
const reducer = createReducer(initialState, handleAction => [
  // Called as soon as the action starts
  handleAction.optimistic(fetchResource, (state, resourceId) => {
    state.loading = true
  }),

  // Optionally, handle errors if your action fails
  handleAction.error(fetchResource, (state, error) => {
    state.loading = false
  }),

  // Called when the action's promise resolves, passing the payload
  handleAction(fetchResource, (state, resource) => {
    state.loading = false
    state.resource = resource
  }),
])

If you prefer to learn by example, take a gander at the examples directory, or check out TodoMVC to see a functioning application.

Installation

Retreon can be installed through npm.

# NPM
npm install retreon

# Yarn
yarn add retreon

Retreon depends on middleware to implement async actions and error handling. Once it's installed, register it with your redux store:

// Wherever you create your redux store...
import { middleware } from 'retreon'

createStore(reducer, applyMiddleware(middleware))

Documentation

Documentation is hosted on the retreon website:


Retreon is inspired by redux-actions and immer.

0.7.0-rc.1

3 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.5.0-rc.1

3 years ago

0.4.0

3 years ago

0.4.0-rc.4

3 years ago

0.4.0-rc.3

3 years ago

0.4.0-rc.2

3 years ago

0.4.0-rc.1

3 years ago

0.3.0

3 years ago

0.2.0

4 years ago

0.1.0

4 years ago