Skip to content

v2.0.2

Latest
Compare
Choose a tag to compare
@pedronauck pedronauck released this 06 Oct 00:16
· 11 commits to master since this release

Changelog

🚀  Features

  • feat: add Provider because of suspense features
  • feat: add subscribe method

⚠️  Breaking Changes

Now you need to wrap your entire application using reworm provider!

import React from 'react'
import { Provider, create } from 'reworm'

const { get } = create({ name: 'John' })

const App = () => (
  <Provider>
    <div>{get(s => s.name)}</div>
  </Provider>
)

Listening state changes

If you want to listen changes on your state you can use subscribe():

import React from 'react'
import { Provider, create } from 'reworm'

const user = create()

class App extends Component {
  state = {
    name: 'John'
  }

  componentDidMount() {
    user.subscribe(name => this.setState({ name }))
    user.set('Michael')
  }

  render() {
    return <div>Hello {this.state.name}</div>
  }
}