omniscientjs / immstruct

Immutable data structures with history for top-to-bottom properties in component based libraries like React. Based on Immutable.js
374 stars 21 forks source link

Get quantity of undo actions #84

Closed reverofevil closed 9 years ago

reverofevil commented 9 years ago

How do I get quantity of available undo actions?

mikaelbr commented 9 years ago

You can check that by doing structure.history.size.

var structure = immstruct.withHistory({ num: 1 });
var cursor = structure.cursor();
cursor = cursor.set('num', 2);
cursor = cursor.set('num', 3);

console.log(structure.history.size); //> 3
reverofevil commented 9 years ago

Thank you!