arqex / freezer

A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
MIT License
1.28k stars 56 forks source link

Using #tansact(): Uncaught TypeError: Cannot read property '__' of undefined #44

Closed christianvogt closed 8 years ago

christianvogt commented 9 years ago

Using #transact() along with store#get and store#set results in the error: Uncaught TypeError: Cannot read property '__' of undefined

This can easily be reproduced using the Undo Redo demo of freezer: http://jsbin.com/hugusi/1/edit?js,output

Find the #handleRemove() function and change the following line:

    this.props.parent.splice( this.props.attrkey, 1 );

to

    var trans = this.props.parent.transact();
    trans.splice( this.props.attrkey, 1 );
    this.props.parent.run();

In the app remove a node and then undo. Subsequent attempts to remove a node results in the exception.

arqex commented 9 years ago

Thanks @zenfe I am on holidays for the next 10 days. I'll have a look at it when I come back ;)

christianvogt commented 9 years ago

My original use case mimics how I'm using Freezer in my app. However I just noticed that even without making the code change to the demo I can reproduce the same exception.

Delete node -> undo -> try to delete the same node = exception

arqex commented 8 years ago

Hey @zenfe

Sorry for the delay addressing this issue, you know holly-days :)

There was a bug binding the parents to the nodes passed to the reset method, that's why there was that error trying to delete the same node.

It should be fixed now in v0.6.1.

I'm looking forward to giving some love to freezer now that I'm back. Stay tuned.