I’m using Code Mirrors, sometimes for very large files, and I have a question.
If I take that string, and I dispatch a transaction with exactly the same very long string, will this be costly?
const veryLongString = 'something very long here';
dispatch({changes: {from: 0, to: state.doc.length: insert: veryLongString}});
dispatch({changes: {from: 0, to: state.doc.length: insert: veryLongString}}); // if I call it multiple times
dispatch({changes: {from: 0, to: state.doc.length: insert: veryLongString}});
dispatch({changes: {from: 0, to: state.doc.length: insert: veryLongString}});
will this be costly? Or will CodeMirror recognize that nothing changes, and will optimize it somehow?
I’m asking because I’m using Vue, and I must do watch on value
, and if value
changes I want to change the state of the editor, but sometimes the watch is called even when value
doesn’t change, value
is the same.
I’m thinking, should I add some kind of checks, if (oldValue != newValue) { dispatch() }
, or no need for it, since it will be optimized?