New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rascl

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rascl

Redux API State Caching Layer

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

RASCL State Diagram RASCL: Redux API State Caching Layer

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.

RASCL State Diagram An API endpoint's state transitions

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.

redux-saga
Manage and compose side effects. Used with RASCL to manage "business logic" in API requests.
ky
A more ergonomic and concise way use the fetch API. Used with RASCL to simplify API client code.
reselect
Compute derived data, memoize complex operations. Used with RASCL to access API response data in a performant way.
typescript
Strongly-typed JavaScript. Used with RASCL to provide type information for API response data and ensure beautiful autocomplete in code editors.


⚠︎ IMPORTANT NOTE
When 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.



Inspiration

Keywords

FAQs

Package last updated on 14 Dec 2022

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