+
Skip to content

goatslacker/alt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alt

A batteries-included, Best Practices™, approach to managing state within large, complex applications.

NPM version Build Status JS.ORG

Install

npm install alt --save

Usage

Action Creators

import Alt from 'alt'

function sendEmail(to, body) {
  // Mocked async call
  return Promise.resolve({
    to,
    body,
  })
}

export default Alt.getActionCreators('Email', {
  send(to, body) {
    return Alt.asyncDispatch(
      sendEmail(to, body)
    )
  },
})

State Branches

import { Branch } from 'alt'

import EmailActions from './EmailActions'
import alt from './alt'

class SentBox extends Branch {
  constructor() {
    this.namespace = 'SentBox'

    this.respondToAsync(EmailActions.send, {
      success: this.emailSent.bind(this),
    })

    this.state = {
      list: [],
    }
  }

  emailSent(email) {
    const { list } = this.state

    this.setState({ list: list.concat(email) })
  }
}

export default alt.addBranch(new SentBox())

Goals & Motivation

This library takes all the good pieces of Alt like single state tree, serialization, loading, ease-of-use, and lays it on top of a Redux-backed foundation with a few utilities included for managing asynchronous actions, and injecting your own branch state managers or reducers at runtime.

  • Async & Error handling in a neat package
  • Injectable reducers
  • Lots of community plugins available
  • Serialization/Loading
  • Small API based on best practices that evolved around Alt

License

MIT

About

Isomorphic flux implementation

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 84

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载