Skip to content

Commit

Permalink
fix: do not use lazyProperty on necessary methods
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbonnet committed Feb 4, 2019
1 parent 17c34bc commit a82ae5a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions src/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ import {
EMPTY_ARRAY,
} from './tools'

function item(element) {
return (index, key = index) => {
const { props } = element
return {
key,
value: props.value && props.value[index],
name: index,
onChange: props.onChange && element.onChangeItem,
}
}
}

function onChangeItem(element) {
return (itemValue, itemIndex, payload) => {
const { props } = element
Expand Down Expand Up @@ -71,6 +59,18 @@ export const array = Component =>
))
*/
class array extends BaseComponent {
constructor(props) {
super(props)
this.item = (index, key = index) => {
const { props } = this
return {
key,
value: props.value && props.value[index],
name: index,
onChange: props.onChange && this.onChangeItem,
}
}
}
render() {
const { props } = this
return $(Component, {
Expand All @@ -81,7 +81,7 @@ export const array = Component =>
onAddItem: props.onChange && lazyProperty(this, 'onAddItem', onAddItem),
onAddItems:
props.onChange && lazyProperty(this, 'onAddItems', onAddItems),
item: lazyProperty(this, 'item', item),
item: this.item,
})
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ import { compose, branch, withHandlers } from 'recompose'

import { hasProp, setProperty, lazyProperty, EMPTY_OBJECT } from './tools'

function property(element) {
return (name, key = name) => {
const { props } = element
return {
value: props.value && props.value[name],
key,
name,
onChange: props.onChange && element.onChangeProperty,
}
}
}

function onChangeProperty(element) {
return (propertyValue, propertyName, payload) => {
const { props } = element
Expand All @@ -34,6 +22,18 @@ export const object = Component =>
Sets `value` to `{}` if not set.
*/
class object extends BaseComponent {
constructor(props) {
super(props)
this.property = (name, key = name) => {
const { props } = this
return {
value: props.value && props.value[name],
key,
name,
onChange: props.onChange && this.onChangeProperty,
}
}
}
render() {
const { props } = this
return $(Component, {
Expand All @@ -42,7 +42,7 @@ export const object = Component =>
onChangeProperty:
props.onChange &&
lazyProperty(this, 'onChangeProperty', onChangeProperty),
property: lazyProperty(this, 'property', property),
property: this.property,
})
}
}
Expand Down

0 comments on commit a82ae5a

Please sign in to comment.