1.1.1 • Published 5 years ago

zlp v1.1.1

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

zlp

非常简单的 react 数据流工具

安装

npm install zlp

使用

// /store/a.js

import { Store } from 'zlp'

class A extends Store {
    // 在 store 属性里管理数据
    store = {
        data: {
            first: 'hello'
        }
    }

    init () {
        this.setStore('data.first', 'hello world')
    }
}

export default new A()

// /view/a.jsx

import { connect } from 'zlp'
import a from '/store/a'

// 一个组件可以绑定多个 store  a\b\c 都是 store 示例
@connect([a, b, c])
class Index extends React.Component {
    render () {
        return (
            <div>
                <h1>{a.store.data.first}</h1>
                <button
                    onClick = {() => a.init()}
                >click</button>
            </div>
        )
    }
}


// 如果不支持修饰符可以用以下使用方式
export default connect([a])(Index)

TODO

  • chrome devtools
1.1.1

5 years ago

1.1.0

5 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago