--
You received this message because you are subscribed to the Google Groups "ShareJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sharejs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Am I doing smth wrong?
I understand how to implement undo, but I faced a problem when trying to implement undo/redo functionality.Let's say we have operations:A B CThen user undoes C and B:A B C C' B'where C'=inverse(C), B'=transform(inverse(B), [C, C'])
Then he redoes B:A B C C' B' B''where B''=transform(B, [C, C', B’])
Then he tries to undo B once again:A B C C' B' B'' B'''where B'''=transform(inverse(B), [C, C', B', B'’])
but B''' becomes [] (noop), but it should be B''' = B’
const json = require('./lib/json0')const _ = require('lodash')const transform = (x, ys) => {return _.reduce(ys, (x, y) => json.transform(x, y, 'left'), x)}let a = [{p: [0], li: 'a'}]let b = [{p: [1], li: 'b'}]let c = [{p: [2], li: 'c'}]let c_ = json.invert(c)let b_ = transform(json.invert(b), [c, c_])let b__ = transform(b, [c, c_, b_])let b___ = transform(json.invert(b), [c, c_, b_, b__])let o = []console.log(o)json.apply(o, a); console.log(o)json.apply(o, b); console.log(o)json.apply(o, c); console.log(o)json.apply(o, c_); console.log(o)json.apply(o, b_); console.log(o)json.apply(o, b__); console.log(o)json.apply(o, b___); console.log(o)console.log('b_ =', b_) // [ { p: [ 1 ], ld: 'b' } ]console.log('b___ =', b___) // []
--
You received this message because you are subscribed to the Google Groups "ShareJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sharejs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.