Comparing version 0.20.4 to 0.20.5
function setAllChecked (args, state) { | ||
let visibleTodos = state.get(['visibleTodos']); | ||
let visibleTodosRefs = state.get(['visibleTodosRefs']); | ||
state.set('isAllChecked', visibleTodos.filter(function(todo) { | ||
state.set('isAllChecked', visibleTodosRefs.filter(function(todo) { | ||
return !todo.completed; | ||
}).length === 0 && visibleTodos.length !== 0); | ||
}).length === 0 && visibleTodosRefs.length !== 0); | ||
@@ -9,0 +9,0 @@ }; |
@@ -5,3 +5,3 @@ function setVisibleTodos (args, state) { | ||
let filter = state.get('filter'); | ||
let visibleTodos = Object.keys(todos).filter(function(key) { | ||
let visibleTodosRefs = Object.keys(todos).filter(function(key) { | ||
@@ -16,3 +16,3 @@ let todo = todos[key]; | ||
}); | ||
state.set(['visibleTodos'], visibleTodos); | ||
state.set(['visibleTodosRefs'], visibleTodosRefs); | ||
@@ -19,0 +19,0 @@ }; |
@@ -8,3 +8,3 @@ import React from 'react'; | ||
@Cerebral({ | ||
visibleTodos: ['visibleTodos'], | ||
visibleTodos: 'visibleTodos', | ||
todos: ['todos'], | ||
@@ -11,0 +11,0 @@ recorder: ['recorder'], |
@@ -6,3 +6,3 @@ import React from 'react'; | ||
@Cerebral({ | ||
todos: ['visibleTodos'], | ||
todos: 'visibleTodos', | ||
isAllChecked: ['isAllChecked'] | ||
@@ -9,0 +9,0 @@ }) |
@@ -13,3 +13,3 @@ import Controller from './../src/index.js'; | ||
todos: {}, | ||
visibleTodos: [], | ||
visibleTodosRefs: [], | ||
newTodoTitle: '', | ||
@@ -29,5 +29,5 @@ isSaving: false, | ||
controller.compute({ | ||
visibleTodos: function (get, refs) { | ||
return refs.map(function (id) { | ||
return get('todos')[id]; | ||
visibleTodos: function (get) { | ||
return get(['visibleTodosRefs']).map(function (id) { | ||
return get(['todos', id]); | ||
}); | ||
@@ -34,0 +34,0 @@ } |
{ | ||
"name": "cerebral", | ||
"version": "0.20.4", | ||
"version": "0.20.5", | ||
"description": "A state controller with its own debugger", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -9,4 +9,5 @@ var utils = require('./utils.js'); | ||
var initialRun = true; | ||
var currentState = {}; | ||
var currentValue = null; | ||
var currentValue; | ||
@@ -20,14 +21,16 @@ var get = function(path) { | ||
var isSame = Object.keys(currentState).reduce(function (hasChanged, key) { | ||
var hasChanged = Object.keys(currentState).reduce(function (hasChanged, key) { | ||
if (hasChanged) { | ||
return true; | ||
} | ||
return model.accessors.get(key.split('.')) === currentState[key]; | ||
return model.accessors.get(key.split('.')) !== currentState[key]; | ||
}, false); | ||
if (isSame) { | ||
return currentValue; | ||
} else { | ||
if (hasChanged || initialRun) { | ||
currentState = {}; | ||
initialRun = false; | ||
return currentValue = cb(get); | ||
} else { | ||
return currentValue; | ||
} | ||
@@ -34,0 +37,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
305827
3725