react-subscription-view

0.1.1 • Public • Published

react-subscription-view

HOC render-function for subscribe() compatible objects

Example

in main.jsy :
::
  const app_model = new MyAppModel().init('example')
 
  setInterval @
    () => app_model.increment()
    1000
 
  ReactDOM.render @
    <App model={app_model} />
    window.main
 
in app/view.jsy :
import reactSubscribedView from 'react-subscribed-view'
const subscribedViewOf = reactSubscribedView(React)
 
export function App({model}) ::
  subscribedViewOf @ model, model => @
    <b>App name: {model.name} counter: {model.counter}</b>
in app/model.jsy :
import {ObjectFunctional} from 'object-functional'
 
export class MyAppModel extends ObjectFunctional ::
 
  asAction = this.init
  init(name) ::
    this.name = name
    this.counter = 0
    return this
 
  asAction = this.increment
  increment(d=1) ::
    this.counter += d
    return this
 
  format() ::
    return `Counter "${this.name}": ${this.counter}`

Readme

Keywords

none

Package Sidebar

Install

npm i react-subscription-view

Weekly Downloads

1

Version

0.1.1

License

BSD-2-Clause

Unpacked Size

55.1 kB

Total Files

12

Last publish

Collaborators

  • shanewholloway