Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

state-tree

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

state-tree - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

2

package.json
{
"name": "state-tree",
"version": "0.1.8",
"version": "0.1.9",
"description": "A state tree that handles reference updates and lets you flush a description of changes",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -34,3 +34,3 @@ var React = require('react');

var propsToPass = Object.keys(paths || {}).reduce(function (props, key) {
props[key] = typeof paths[key] === 'object' ? paths[key].get() : tree.get(paths[key]);
props[key] = typeof paths[key] === 'object' ? paths[key].get(tree.get()) : tree.get(paths[key]);
return props

@@ -37,0 +37,0 @@ }, {})

@@ -215,3 +215,3 @@ # state-tree (EXPERIMENTAL)

myComputed.get() // "bar!!!"
myComputed.get(tree) // "bar!!!"
let changes = tree.flushChanges(); // {}

@@ -222,3 +222,3 @@ myComputed.hasChanged(changes); // false

myComputed.hasChanged(changes); // true
myComputed.get() // "bar2!!!"
myComputed.get(tree) // "bar2!!!"
```

@@ -231,4 +231,9 @@ So, this seems like a lot of code to make computed work, but again, this is low level. Implemented in the HOC of React you can simply do this.

import addItem from './addItem';
import awesomeItems from './computed/awesomeItems';
const awesomeItems = computed({
list: 'list' // Define its deps
}, state => {
return state.list.filter(item => item.isAwesome);
});
function Items(props) {

@@ -249,13 +254,3 @@ return (

```
And *awesomeItems.js* would look like:
```js
import tree from './tree';
export default tree.computed({
list: 'list' // Define its deps
}, state => {
return state.list.filter(item => item.isAwesome);
});
```
There is no magic going on here. The components will pass in the flushed "change tree" to whatever computed they have. This is what tells them to verify if an update is necessary, if not already ready to calculate a new value.

@@ -235,3 +235,3 @@ var subscribers = [];

return {
get: function (changes) {
get: function (passedState) {
if (computedHasChanged) {

@@ -241,3 +241,3 @@ computedHasChanged = false;

var path = deps[key].split('.');
props[key] = getByPath(path, state);
props[key] = getByPath(path, passedState);
return props;

@@ -244,0 +244,0 @@ }, {}));

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc