rigby
TypeScript icon, indicating that this package has built-in type declarations

1.5.2 • Public • Published

Build Status

rigby

React is great, but... y'know

Installation

npm i rigby

Creating a Store

 
Rigby.createStore('YourStoreName', {
  state: {
    todos: [
      { 
        text: 'Your Data Goes Here',
        complete: false
      }
    ]
  },
  actions: {
    addTodo: function(text, complete) {
      this.state.todos.push({ text: text, complete: complete });
      this.emitChange();
    }
  }
});
 

Or with ES2015+:

import Store from "rigby";
 
class YourStore extends Store {
  constructor() {
    super("YourStoreName");
 
    this.state.todos = [ 
      { text: "Your Data Goes Here", complete: false }
    ];
  }
 
  addTodo(text, complete) {
      this.state.todos.push({ text, complete });
      this.emitChange();
  }
}
 

Or with TypeScript:

import Store from "rigby";
 
interface ToDo {
  text: string;
  complete: boolean;
}
 
interface YourStoreState {
  todos: ToDo[];
}
 
class YourStore extends Store<YourStoreState> {
  constructor() {
    super("YourStoreName");
 
    this.state.todos = [ 
      { text: "Your Data Goes Here", complete: false }
    ];
  }
 
  addTodo(text: string, complete: boolean) {
      this.state.todos.push({ text, complete });
      this.emitChange();
  }
}
 

Dispatching Actions

import Rigby from "rigby";
 
Rigby.dispatch("addTodo", "Your New Todo", false);

Why

Less boilerplate when creating Stores and a more fluent API for doing so.

Plans

This is a thought experiment, and there are plans for versions that allow for using RxJS or move in the direction of things like Cycle and Yolk.

Readme

Keywords

none

Package Sidebar

Install

npm i rigby

Weekly Downloads

22

Version

1.5.2

License

MIT

Last publish

Collaborators

  • captray
  • paulirwin