Skip to content

Commit

Permalink
Bumps to version 0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
arqex committed Feb 19, 2018
1 parent b47a667 commit 1698024
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Freezer Changelog

###v0.14.0
* Adds a new flag `singleParent` that prevents the same node to be added twice into the the state tree. Thanks to @nathanial.

###v0.13.0
* Fixes bug making apps unresponsive in FF when an error happens in a listener.

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ var freezer = new Freezer({hi: 'hello'}, {mutable: true, live:true});
| **mutable** | boolean | `false` | Once you get used to freezer, you can see that immutability is not necessary if you learn that you shouldn't update the data directly. In that case, disable immutability in the case that you need a small performance boost. |
| **live** | boolean | `false` | With live mode on, freezer emits the update events just when the changes happen, instead of batching all the changes and emiting the event on the next tick. This is useful if you want freezer to store input field values. |
| **freezeInstances** | boolean | `false` | It's possible to store class instances in freezer. They are handled like strings or numbers, added to the state like non-frozen leaves. Keep in mind that if their internal state changes, freezer won't `emit` any update event. If you want freezer to handle them as freezer nodes, set 'freezerInstances: true'. They will be frozen and you will be able to update their attributes using freezer methods, but remember that any instance method that update its internal state may fail (the instance is frozen) and wouldn't emit any `update` event. |
| **singleParent** | boolean | `false` | Freezer allows to add the same node to different parts of the state tree. Updating that node will update all its references that the current state contains. This is a nice feature but it's not ideal if you don't want circular dependencies in your state, in that case set it to `true`. |

And then, Freezer's API is really simple and only has 2 methods: `get` and `set`. A freezer object also implements the [listener API](#listener-api).

Expand Down
8 changes: 6 additions & 2 deletions build/freezer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* freezer-js v0.13.0 (3-7-2017)
/* freezer-js v0.14.0 (19-2-2018)
* https://github.com/arqex/freezer
* By arqex
* License: MIT
Expand Down Expand Up @@ -880,6 +880,9 @@ var Frozen = {
;

if( index === -1 ){
if(node.__.store.singleParent && parents.length >= 1){
throw new Error("Freezer: Can't add node to the tree. It's already added and freezer is configured to `singleParent: true`.");
}
parents[ parents.length ] = parent;
}
},
Expand Down Expand Up @@ -945,7 +948,8 @@ var Freezer = function( initialValue, options ) {
ops = options || {},
store = {
live: ops.live || false,
freezeInstances: ops.freezeInstances || false
freezeInstances: ops.freezeInstances || false,
singleParent: ops.singleParent || false
}
;

Expand Down
4 changes: 2 additions & 2 deletions build/freezer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "freezer-js",
"version": "0.13.0",
"version": "0.14.0",
"description": "A tree data structure that is always updated from the root, making easier to think in a reactive way.",
"main": "freezer.js",
"homepage": "https://github.com/arqex/freezer",
Expand Down
2 changes: 1 addition & 1 deletion src/frozen.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ var Frozen = {

if( index === -1 ){
if(node.__.store.singleParent && parents.length >= 1){
throw new Error('Node already has a parent');
throw new Error("Freezer: Can't add node to the tree. It's already added and freezer is configured to `singleParent: true`.");
}
parents[ parents.length ] = parent;
}
Expand Down

0 comments on commit 1698024

Please sign in to comment.