All Projects → neurosnap → robodux

neurosnap / robodux

Licence: MIT license
caching in redux made simple

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to robodux

Pike
HTTP cache server, such as varnish
Stars: ✭ 155 (+58.16%)
Mutual labels:  caching
Scaffeine
Thin Scala wrapper for Caffeine (https://github.com/ben-manes/caffeine)
Stars: ✭ 195 (+98.98%)
Mutual labels:  caching
Eram
Open Source RAM Disk
Stars: ✭ 227 (+131.63%)
Mutual labels:  caching
Haproxy
HAProxy Load Balancer's development branch (mirror of git.haproxy.org)
Stars: ✭ 2,463 (+2413.27%)
Mutual labels:  caching
Mahuta
IPFS Storage service with search capability
Stars: ✭ 185 (+88.78%)
Mutual labels:  caching
Alfred Workflow
Full-featured library for writing Alfred 3 & 4 workflows
Stars: ✭ 2,622 (+2575.51%)
Mutual labels:  caching
Mvcdonutcaching
ASP.NET MVC Extensible Donut Caching brings donut caching to ASP.NET MVC 3 and later. The code allows you to cache all of your page apart from one or more Html.Actions which can be executed every request. Perfect for user specific content.
Stars: ✭ 146 (+48.98%)
Mutual labels:  caching
wizards-apollo
An application for my talk about caching management with Apollo Client 3
Stars: ✭ 54 (-44.9%)
Mutual labels:  caching
Simple Spring Memcached
A drop-in library to enable memcached caching in Spring beans via annotations
Stars: ✭ 185 (+88.78%)
Mutual labels:  caching
Varnish Cache
Varnish Cache source code repository
Stars: ✭ 2,769 (+2725.51%)
Mutual labels:  caching
Safer
🧿 safer writing in Python 🧿
Stars: ✭ 166 (+69.39%)
Mutual labels:  caching
Siesta
The civilized way to write REST API clients for iOS / macOS
Stars: ✭ 2,142 (+2085.71%)
Mutual labels:  caching
Joblib
Computing with Python functions.
Stars: ✭ 2,620 (+2573.47%)
Mutual labels:  caching
Cachemanager
CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
Stars: ✭ 2,049 (+1990.82%)
Mutual labels:  caching
Cacheout
A caching library for Python
Stars: ✭ 238 (+142.86%)
Mutual labels:  caching
Libcache
A Lightweight in-memory key:value cache library for Go.
Stars: ✭ 152 (+55.1%)
Mutual labels:  caching
Stash
Stash allows you to stash text and snippets of code for reuse throughout your templates.
Stars: ✭ 198 (+102.04%)
Mutual labels:  caching
cashews
Cache with async power
Stars: ✭ 204 (+108.16%)
Mutual labels:  caching
Quell
Quell is an easy-to-use, lightweight JavaScript library providing a client- and server-side caching solution for GraphQL. Use Quell to prevent redundant client-side API requests and to minimize costly server-side response latency.
Stars: ✭ 473 (+382.65%)
Mutual labels:  caching
Crafatar
A blazing fast API for Minecraft faces
Stars: ✭ 212 (+116.33%)
Mutual labels:  caching

robodux

ci

One of the biggest complaints developers have with redux is the amount of boilerplate and new concepts they have to learn to use it. By using the robodux pattern the amount of redux boilerplate is dramatically reduced. In most cases, wiring up action types, action creators, and reducers can be done in one line of code.

Features

  • Create actions, reducer, and selectors for common data structures
  • Automates the boring parts of redux
  • Dramatically reduces redux boilerplate
  • Works well with saga-query

What's included

  • createTable: Thinking of reducers as database tables, this function builds actions, reducer, and selectors that builds simple and repeatable operations for that table.
  • createAssign: A catch-all data structure that makes it easy to set or reset the reducer.
  • createList: Store an array of items in a slice
  • createLoaderTable: Store as many independent loaders in this reducer which are all accessible by an id.
  • createSlice: Core function that the above slice helpers leverage. Build action types, action creators, and reducer pairs with one simple function.
  • and more!

Core principles

The overriding principle is that effects (like sagas) should be the central processing unit for all business logic in a react/redux application. We should remove as much business logic as possible from reducers and instead centralize them inside of our side-effect handlers.

The other primary principle is to think of redux as a database and reducers as tables. This simplifies the action/reducer logic and makes it possible to build reuseable components which dramatically reducers boilerplate.

Please see style-guide for more details.

Getting started

yarn add robodux

Usage

The primary philosophical change between this library and other libraries is to think of your redux store as a database.

Reducers are database tables and operating on those tables should have a consistent API for managing them.

robodux has a few slice helpers that cover ~90% of the logic and data structures needed to build and scale your state.

These are one-line functions that create action types, action creators, and reducers using a simple set of lower-level functions. There's no magic here, it's more of how we think about our state that has made it dramatically simple to automate repetitive tasks in redux.

One of the more useful APIs from this library is createTable. This slice helper creates a reducer and a set of actions that make it easy to treat a slice as a database table.

import { combineReducers, createStore } from 'redux';
import { createTable, createReducerMap, MapEntity } from 'robodux';

// setup reducer state
interface Comment {
  message: string;
  timestamp: number;
}

interface State {
  comments: MapEntity<Comment>;
}

// create reducer and actions
const comments = createTable<Comment>({ name: 'comments' });

// converts multiple slices into an object of reducers to be used with combineReducers
// { comments: (state, action) => state }
const reducers = createReducerMap(comments);
const rootReducer = combineReducers(reducers);
const store = createStore(rootReducer);

// dispatch action to add a record to our table
store.dispatch(
  actions.add({
    1: { message: 'you awake?', timestamp: 1577117359 },
  }),
);
// { comments: { 1: { message: 'you awake?', timestamp: 1577117359 } } }

store.dispatch(
  actions.patch({
    1: { message: 'Are you awake?' },
  }),
);
// { comments: { 1: { message: 'Are you awake?', timestamp: 1577117359 } } }

const selectors = comments.getSelectors((state) => state[comments.name]);

const state = store.getState();
const commentMap = selectors.selectTable(state);
const commentList = selectors.selectTableAsList(state);
const commentOne = selectors.selectById(state, { id: '1' });
const foundComments = selectors.selectByIds(state, { ids: ['1', '3'] });

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].