0.4.1 • Published 7 years ago

nervnode v0.4.1

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

nervnode 是什么

解决 React-like 框架中 Component 之间的通信问题,提供异于 Redux 的跨组件通信的解决方案

nervnode 支持的 React-like 库

- [v] Inferno
- [v] React
- [x] Preact

安装

    npm install nernode --save
    yarn add nervnode

用法

const Component from inject
const { insertNerv } from 'nervnode'

class Ping extends Component {
  constructor(props) {
    super(props)
    this.state = { message: '' }
  }
  
  componentDidMount() {
    // 此组件加载完成后即可发送相应的 Message
    this.props.pong()
  }
  
  componentWillReceiveProps(nextProps) {
    this.setState({ message: nextProps.message }) 
  }
  
  render() {
    return <div />
  }
}

const listenFunc = (setProps, localContext) {
  return {
    'ping': (msg) => setProps({ message: msg.message })
  }
}

const dispatchFunc = (dispatch, localContext) {
  return {
    pong: () => dispatch('pong', {})
  }
}

const filter = {
  in: ['*'],
  out: ['*'],
}

const PintNerv = insertNerv(listenFunc, dispatchFunc, filter)(Ping)
0.4.1

7 years ago

0.4.0

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago