1.0.4 • Published 1 year ago

rascl v1.0.4

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
1 year ago

npm Codecov GitHub Workflow Status (branch) GitHub Workflow Status (branch)

RASCL is an opinionated library that creates "zero boilerplate" bridges between API clients and Redux.


Table of Contents


Documentation


Why RASCL?

Trying to follow established best practices for Redux often results in repetitious code. Because this type of code is tedious to write and time-consuming to maintain, it's also a frequent source of "copy/paste" errors.

Libraries like redux-actions and redux-act already reduce some of this boilerplate, but RASCL goes further and removes it all.

How it works

Given a map of API calls, RASCL can generate every part of a complete Redux and Redux-Saga setup:

import * as MyAPI from "./API";

const { createRASCL } = await import("rascl");

export const {
  types,         // String constants for action types
  actions,       // Action creator functions
  initialState,  // Initial Redux store state
  handlers,      // Action handlers for state updates
  watchers,      // Sagas to respond to each type of action
  reducer,       // A root reducer
  rootSaga,      // A root saga
} = createRASCL(MyAPI);

RASCL then tracks the "lifecycle" of each API call as a finite state machine. As the API call "moves" through the lifecycle, each stage dispatches a Redux action containing the relevant data.

The data contained in each action is cached in the Redux store, from the initial request parameters through to the successful API result or the details of an error.

This makes logging and debugging extremely straightforward, and upholds a core principle of RASCL: All the data is always available.

Therefore, once RASCL is configured and invoked, an application only needs to do two things:

  1. Dispatch Redux actions to indirectly make API requests
  2. Use selector functions to indirectly access the results

Installation

npm i -S rascl

or

yarn add rascl

Optional Dependencies

RASCL works extremely well with a collection of other packages, but none of these is strictly necessary for RASCL to function.

⚠︎ IMPORTANT NOTEWhen used with TypeScript, RASCL's type declarations require TypeScript version 4.2 or greater due to a dependency on Template Literal Types. Earlier versions of TypeScript will produce opaque errors.

Related Concepts

Inspiration

1.0.4

1 year ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-rc.3

3 years ago

1.0.0-rc.1

3 years ago

1.0.0-rc.2

3 years ago

1.0.0-rc.0

3 years ago