state-lens
State cursor/lens thing
Last updated 5 years ago by ashaffer88 .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install state-lens 
SYNC missed versions from official npm registry.

state-lens

js-standard-style

State cursor/lens thing

Installation

$ npm install state-lens

Usage

Just an experiment right now to create a minimal state lens/cursor thing to use for local state in deku.

Deku component wrapper

function localize (component) {
  if ('function' === typeof component) {
    component = {render: component}
  }

  const {onCreate = () => {}, onRemove = () => {}, initialState = () => ({})} = component

  component.onCreate = (model) => {
    model.dispatch(model.props.state.create(initialState(model)))
    return onCreate(model)
  }

  component.onRemove = (model) => {
    model.dispatch(model.props.state.destroy())
    return onRemove(model)
  }

  return component
}

Current Tags

  • 0.2.0                                ...           latest (5 years ago)

1 Versions

  • 0.2.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (1)
Dev Dependencies (11)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |