0.8.4 • Published 5 years ago

rako v0.8.4

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Rako

LICENSE

Introduction

Rako is a declarative state container for Javascript apps.

Rako is like a Controller in MVC.

mvc

Installation

yarn add rako or npm install rako.

Work with React

rako-react: https://github.com/rabbitooops/rako-react

Example

rako-react-example: https://codesandbox.io/s/011136qpkn

After you open the link of codeSandbox above, because codeSandbox doesn't support console.group, please press Ctrl + Shift + J(on Windows) or Ctrl + Option + J(on macOS) to open `DevTools > Console`.

example

API

createStores(...producers: Array<function>): Array<Store>

withMiddlewares(...middlewares: Array<function>): createStores

store.subscribe(listener: function): unsubscribe

store.getState(): object

store.getActions(): object

Usage of producer:

function producer(getState) {

  // you can't call `getState()` as constructing `Store`, otherwise it will cause an error.
  // getState()

  return {
    value: 0,
    doSomething(value) {
      this.setState({value})
    },
    doSomethingAsync(value) {
      setTimeout(() => {
        this.setState({value})
      }, 1000)
    },
    doAnythingYouWant() {
      const {value} = getState()

      // Network request, calculation, whatever you want, Rako is like a Controller in MVC.
      networkRequest(value)
      calculation(value)
      this.setState({value: value + 1})
    }
  }
}

getState() in producer is equivalent to store.getState(), but you can't getState() as constructing Store.

this.setState(substate: object, extra: any?)

Note

The concept of action in Rako is different to Redux's. You can learn MVC mentioned before.

0.8.4

5 years ago

0.8.3

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.5

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.3

5 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago