Giter VIP home page Giter VIP logo

repaar's Introduction

repaar library logo

repaar

Pronounced "repair"

JavaScript state-management with unprecedented ease-of-use and performance by combining the best of redux and mobx.

Overview

rematch is a library with the intent to simplify redux even more and is used as the basis for repaar. Unfortunately rematch doesn't solve some of the core issues with redux, which have been solved by mobx though. So for repaar a small library from the mobx creator called immer was included. By including this library the state inside the reducers can be mutated instead of always recreating the state again by hand. With this approach immutability without any additional effort and minimal effects on performance is achieved.

Includes

  • Immutability from immer
    • Writing regular JS inside reducers
    • Performance comparable to using ImmutableJS
  • Middleware from redux
  • Async effects from rematch
    • No redux-thunk necessary

Avoids

  • Recreating state by hand with Object.assign()
  • No classes, state stored as POJO
  • No decorators which are still experimental syntax

Installation

npm i repaar

Getting Started

import { init } from 'repaar'

const todo = {
  state: {
    username: '',
    items: [{
      title: 'Enter a username to get started.',
      done: false
    }]
  },
  reducers: {
    auth(state, username) {
      state.username = username
    },
    add(state, title) {
      const item = {title, done: false}
      state.items.push(item)
    },
    complete(state, index) {
      state.items[index].done = true
    }
  }
}

const store = init({
  models: {
    overlay,
  }
})

store.dispatch({type: 'todo/auth', payload: 'repaar'})
store.dispatch({type: 'todo/complete', payload: 0})
store.dispatch({type: 'todo/add', payload: 'Say Hello World'})

const state = store.getState()

=>
{
  username: 'repaar',
  items: [
    {title: 'Enter ...', done: true}, {title: 'Say ...', done: false}
  ]
}

React, Vue and Angular

See TODO.

Roadmap

  • General renaming (a reducer doesn't reduce anything)
  • Computed values built in
  • Single object, no namespaces
  • Anonymous actions

License

MIT

repaar's People

Contributors

shmck avatar blairbodnar avatar pierissimo avatar crazy4groovy avatar jackwilsdon avatar kamerontanseli avatar titouancreach avatar bosung90 avatar felipedeboni avatar kaddopur avatar markogresak avatar taranda avatar levito avatar wmertens avatar eveningkid avatar xiaohesong avatar

Watchers

Matthias Giger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.