All Projects → ruanyl → Reapex

ruanyl / Reapex

Licence: mit
A lightweight framework to build pluggable and extendable redux/react application

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Reapex

Redux Orm
A small, simple and immutable ORM to manage relational data in your Redux store.
Stars: ✭ 2,922 (+4937.93%)
Mutual labels:  reducer, selector
k-redux-factory
Factory of Redux reducers and their associated actions and selectors.
Stars: ✭ 18 (-68.97%)
Mutual labels:  selector, reducer
cra-redux-boilerplate
⚛️🔨create-react-app application with redux and another cool libraries to make your life easier.
Stars: ✭ 15 (-74.14%)
Mutual labels:  selector, reducer
Redux Dynamic Modules
Modularize Redux by dynamically loading reducers and middlewares.
Stars: ✭ 874 (+1406.9%)
Mutual labels:  sagas, reducer
Async Reduce
Reducer for similar simultaneously coroutines
Stars: ✭ 17 (-70.69%)
Mutual labels:  reducer
Redux Saga
An alternative side effect model for Redux apps
Stars: ✭ 21,975 (+37787.93%)
Mutual labels:  sagas
Repatch
Dispatch reducers
Stars: ✭ 516 (+789.66%)
Mutual labels:  reducer
Scrapple
A framework for creating semi-automatic web content extractors
Stars: ✭ 464 (+700%)
Mutual labels:  selector
Layui dropdown
基于layui框架的下拉控件,支持菜单下拉,自定义下拉内容,兼容表格。
Stars: ✭ 40 (-31.03%)
Mutual labels:  selector
Redux Tide
Simple library for redux crud normalized state and actions/selectors for it
Stars: ✭ 20 (-65.52%)
Mutual labels:  selector
Domtastic
Small, fast, and modular DOM and event library for modern browsers.
Stars: ✭ 763 (+1215.52%)
Mutual labels:  selector
Cheerio
Fast, flexible, and lean implementation of core jQuery designed specifically for the server.
Stars: ✭ 24,616 (+42341.38%)
Mutual labels:  selector
Puddles
Tiny vdom app framework. Pure Redux. No boilerplate.
Stars: ✭ 24 (-58.62%)
Mutual labels:  reducer
Redux Ecosystem Links
A categorized list of Redux-related addons, libraries, and utilities
Stars: ✭ 5,076 (+8651.72%)
Mutual labels:  reducer
Jes
Java Event Store implementation
Stars: ✭ 32 (-44.83%)
Mutual labels:  sagas
Android Sku
🔥 Android Sku属性选择器, 类似于淘宝,天猫,京东,支持MVVM,直接使用
Stars: ✭ 500 (+762.07%)
Mutual labels:  selector
Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (+1208.62%)
Mutual labels:  selector
Iconswitch
🍭 Custom Android Switch widget
Stars: ✭ 874 (+1406.9%)
Mutual labels:  selector
Useeffectreducer
useReducer + useEffect = useEffectReducer
Stars: ✭ 642 (+1006.9%)
Mutual labels:  reducer
Mobile Select
手机移动端选择组件 支持是否级联/单选到多选/可异步更新数据等..
Stars: ✭ 829 (+1329.31%)
Mutual labels:  selector

Reapex

Reapex is a lightweight "framework" written in TypeScript to build pluggable and extendable redux(react) application

Reapex is designed in a way that modules have a clear boundary with each other, it forces people to think in a modularized way when working with Reapex.

Reapex supports plugins which make it easy to share reusable modules among projects. Or even publishing to npm. Such as reapex-plugin-dataloader

Built with the love of TypeScript

Reapex is written with TypeScript and it offers strongly typed state, selectors, actions.

Features

  • [x] Reapex will automatically create actions/action types, much less boilerplate which makes app easy to maintain and refactor
  • [x] Reapex loads modules dynamically, sagas/reducers are registered dynamically which makes code-splitting easy
  • [x] Plugin support, create reusable and shareable code easily
  • [x] Lightweight, easy to integrate with existing react/redux/redux-sagas application

Examples

  1. Counter: A legendary Counter example
  2. Login Form: Side effects handling with the demo of API call

Getting started with a simple Counter example

npm i reapex --save

Install peer dependencies

npm i react react-dom redux react-redux redux-saga --save

1. Initialize the application

import { App } from 'reapex'

const app = new App()

2. Create a model(the shape of the state)

const counter = app.model('Counter', { total: 0 })

3. Defined the mutations: how you want the state to be mutated

Mutation combines action types and reducer, and it returns action creators

const [mutations] = counter.mutations({
  increase: (t: number) => s => s.set('total', s.total + t),
  decrease: () => s => s.set('total', s.total - 1),
})

The function: (t: number) => s => s.set('total', s.total + t), t: number will be the input parameter of the action creator. s is a typed immutable Record<{total: number}>. By running the code above you will get an action creator map as:

{
  increase: (t: number) => ({ type: 'Counter/increase',  payload: [t] })
  decrease: () => ({ type: 'Counter/decrease' })
}

4. Connect it with Component

react-redux users should be very familiar with the following codes, it is a typical react-redux container, but with action creators and selectors which automatically created by reapex.

import React from 'react'
import { useSelector, useDispatch, Provider } from 'react-redux'

export const Counter = () => {
  const total = useSelector(CounterModel.selectors.total)
  const dispatch = useDispatch()
  
  return (
    <>
      <button onClick={() => dispatch(mutations.decrease())}>-</button>
      {props.total}
      <button onClick={() => dispatch(mutations.increase(2))}>+2</button>
    </>
  )
}

Note: counter.state.get('total') provides the selector to the total

5. Render it!

import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'

const store = app.createStore()

render(
  <Provider store={store}>
    <Counter />
  </Provider>,
  document.getElementById('root')
)
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].