Socket
Book a DemoInstallSign in
Socket

odux

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

odux

observable redux

latest
Source
npmnpm
Version
0.3.13
Version published
Weekly downloads
12
-20%
Maintainers
1
Weekly downloads
 
Created
Source

Odux

English | 简体中文

CI Coverage Version License

A friendly and easy-to-use front-end state management library. (need TypeScript)

Feature

  • Out of box, Low learning costs and less concept
  • Type friendly, Describe the data model using OO, intuitive
  • Easy to integrate, Can be seamlessly integrated into the other Redux-based state management system, or run independently from Redux

Install

npm i odux --save

Quick Start

First

TypeScript config:

// tsconfig.json
{
  "compilerOptions": {
    ...
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Store/Model

class AStore extends BaseStore {
  testData = {
    str: 'Hello World!',
    count: 0,
  };

  add() {
    this.testData.count++;
  }
}

Component

@connect()
class App extends PureComponent {
  @inject()
  aStore: AStore;

  onClick = () => {
    this.aStore.add();
  };

  render() {
    const { testData } = this.aStore;
    return (
      <div>
        <p>{testData.str}</p>
        <p>count: {testData.count}</p>
        <button onClick={this.onClick}>Add</button>
      </div>
    );
  }
}

Demo

Integration with other redux-base

dva

const odux = createOduxForDva();
const app = dva({
  extraEnhancers: [odux.extraEnhancers],
  onReducer: odux.onReducer,
  // onReducer: reducer => otherReducer(odux.onReducer(reducer)),
});

createOduxEnhancer

Thanks

immer

Keywords

react

FAQs

Package last updated on 09 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts