set method
void
set(})
Implementation
void set(T val,
{bool save = true,
bool noUndo = false,
bool dontChangeBookTime = false,
bool dontRealTime = false,
void Function(T val)? doComplete,
void Function(T val)? undoComplete}) {
if (val == _value) return; // 값이 동일하다면, 할 필요가 없다.
if (noUndo) {
_value = val;
if (save && saveManagerHolder != null && _mid.isNotEmpty) {
//print('noUndo pushChanged $hint');
saveManagerHolder!.pushChanged(
_mid,
'execute $hint',
dontChangeBookTime: dontChangeBookTime,
dontRealTime: dontRealTime,
);
}
return;
}
MyChange<T> c = MyChange<T>(_value, mid: _mid, execute: () {
_value = val;
//print('new MyChange $_value, $_mid');
if (save && saveManagerHolder != null && _mid.isNotEmpty) {
//print('pushChanged $hint $_mid');
saveManagerHolder!
.pushChanged(_mid, 'execute $hint', dontChangeBookTime: dontChangeBookTime);
}
}, redo: () {
//print('redo old=$val, new=$_value');
_value = val;
if (save && saveManagerHolder != null && _mid.isNotEmpty) {
saveManagerHolder!.pushChanged(_mid, 'redo $hint', dontChangeBookTime: dontChangeBookTime);
}
doComplete?.call(_value);
}, undo: (T old) {
if (old == _value) return; // 값이 동일하다면, 할 필요가 없다.
_value = old;
//print('undo old=$old, new=$_value,_mid=$_mid, save=$save,');
if (save && saveManagerHolder != null && _mid.isNotEmpty) {
saveManagerHolder!.pushChanged(_mid, 'undo $hint', dontChangeBookTime: dontChangeBookTime);
}
undoComplete?.call(_value);
});
mychangeStack.add(c);
}