All Projects → rohan-deshpande → trux

rohan-deshpande / trux

Licence: MIT license
Unidirectional data layer for reactive user interfaces

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to trux

Roxie
Lightweight Android library for building reactive apps.
Stars: ✭ 441 (+647.46%)
Mutual labels:  state-management, unidirectional-data-flow
NestedReact
BackboneJS compatibility layer for React-MVx MVVM framework.
Stars: ✭ 79 (+33.9%)
Mutual labels:  state-management, unidirectional-data-flow
Teapot
Unidirectional Dataflow library for Android inspired by The Elm Architecture
Stars: ✭ 29 (-50.85%)
Mutual labels:  state-management, unidirectional-data-flow
Rxstate
Redux implementation in Swift using RxSwift
Stars: ✭ 142 (+140.68%)
Mutual labels:  state-management, unidirectional-data-flow
UniTEA
Implementation of The Elm Architecture for Unity3D
Stars: ✭ 31 (-47.46%)
Mutual labels:  state-management
almy
🗄️ 673 bytes store for managing the state in your application
Stars: ✭ 26 (-55.93%)
Mutual labels:  state-management
mst-effect
💫 Designed to be used with MobX-State-Tree to create asynchronous actions using RxJS.
Stars: ✭ 19 (-67.8%)
Mutual labels:  state-management
gstate
A crazy state management for lazy programmers
Stars: ✭ 27 (-54.24%)
Mutual labels:  state-management
rex-state
Convert hooks into shared states between React components
Stars: ✭ 32 (-45.76%)
Mutual labels:  state-management
unstated
Simple state management for react
Stars: ✭ 12 (-79.66%)
Mutual labels:  state-management
XUI
XUI makes modular, testable architectures for SwiftUI apps a breeze!
Stars: ✭ 100 (+69.49%)
Mutual labels:  state-management
Xamarin.Components-Architecture
A humble attempt to make Xamarin follows the components architecture
Stars: ✭ 20 (-66.1%)
Mutual labels:  component-driven
immutable-cursor
👊 Immutable cursors incorporating the Immutable.js interface over a Clojure-inspired atom
Stars: ✭ 58 (-1.69%)
Mutual labels:  state-management
ngx-mobx
Mobx decorators for Angular Applications
Stars: ✭ 14 (-76.27%)
Mutual labels:  state-management
snap-state
State management in a snap 👌
Stars: ✭ 23 (-61.02%)
Mutual labels:  state-management
atomic-state
Atomic State is a state management library for React
Stars: ✭ 15 (-74.58%)
Mutual labels:  state-management
nstate
A simple but powerful react state management library with low mind burden
Stars: ✭ 11 (-81.36%)
Mutual labels:  state-management
query-param-store
Angular Reactive Query Parameters Store
Stars: ✭ 15 (-74.58%)
Mutual labels:  state-management
NObservable
MobX like observable state management library with Blazor support
Stars: ✭ 66 (+11.86%)
Mutual labels:  state-management
asyncmachine
Relational State Machine with a visual inspector
Stars: ✭ 67 (+13.56%)
Mutual labels:  state-management

Trux

API ⇆ Trux ➝ UI

Unidirectional data layer for reactive user interfaces.

Build Status Coverage Status Dependency Status npm version

Introduction

Trux is an easy-to-use, lightweight and effective way of managing mutable data for your client side JavaScript app.

With its focus placed on enabling the creation of fully customisable bridges between your API and UI, Trux provides convenient and safe ways to mutate data and synchronise these mutations with your components.

With Trux, your data stores become the sources of truth for your app's data driven user interfaces. All you need to do is create some stores, connect components to them and let it do the work.

While it was designed with React and a REST API in mind, Trux can also be used with other view libraries and API systems such as Vue and GraphQL.

Want to learn more? Checkout the quickstart guide below or get an in-depth look by reading the docs.

Installation

npm i -S trux

Polyfills

In order to support older browsers you'll need some polyfills

Quickstart

In Trux, your client side data is kept in stores called models or collections. You connect components to these stores and ask the stores to perform data changes. Your stores can persist these changes to their connected components. You can choose to make these updates either optimistic or pessimistic.

Here's the basic gist, without considering requests to an API

import { Model } from 'trux';

// First we're going to create a Counter model with some starting data.
// By extending the Trux Model class, we get all the functionality we need plus we can add custom methods,
// like the increment and decrement methods which mutate the state of the model.
class Counter extends Model {
  constructor() {
    super({ value: 0 });
  }

  increment() {
    this.data.value++;
    return this;
  }

  decrement() {
    this.data.value--;
    return this;
  }
}

// Instantiate the store
const store = new Counter();

// Now we are going to create a mock component to connect to our store.
// We need to declare a unique truxid and a storeDidUpdate method to receive updates from the store.
const component = {
  truxid: 'TICKER',
  storeDidUpdate: () => {
    console.log(model.data.value);
  }
};

// connect the component to the store.
store.connect(component);
// call the increment and decrement methods then chain persist to see the new value get logged.
store.increment().persist(); // 1
store.increment().persist(); // 2
store.decrement().persist(); // 1
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].