mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
CREATE_MODE(1/2)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
function getIn (object, path) {
|
||||
var stack = path.split('.')
|
||||
let stack = path.split('.')
|
||||
while (stack.length > 1) {
|
||||
object = object[stack.shift()]
|
||||
}
|
||||
@@ -7,8 +7,8 @@ function getIn (object, path) {
|
||||
}
|
||||
|
||||
function updateIn (object, path, value) {
|
||||
var current = object
|
||||
var stack = path.split('.')
|
||||
let current = object
|
||||
let stack = path.split('.')
|
||||
while (stack.length > 1) {
|
||||
current = current[stack.shift()]
|
||||
}
|
||||
@@ -21,7 +21,14 @@ function setPartialState (component, path, value) {
|
||||
updateIn(component.state, path, value))
|
||||
}
|
||||
|
||||
export default function linkState (el, path) {
|
||||
export default function linkState (path) {
|
||||
return {
|
||||
value: getIn(this.state, path),
|
||||
requestChange: setPartialState.bind(null, this, path)
|
||||
}
|
||||
}
|
||||
|
||||
export function linkState2 (el, path) {
|
||||
return {
|
||||
value: getIn(el.state, path),
|
||||
requestChange: setPartialState.bind(null, el, path)
|
||||
|
||||
Reference in New Issue
Block a user