|
|
@ -54,9 +54,18 @@ mixin Changeable<T> { |
|
|
|
@mustCallSuper |
|
|
|
@mustCallSuper |
|
|
|
void onAfterModify() {} |
|
|
|
void onAfterModify() {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Called after the all modifications |
|
|
|
|
|
|
|
@protected |
|
|
|
|
|
|
|
@mustCallSuper |
|
|
|
|
|
|
|
void onAfterAnyModify() {} |
|
|
|
|
|
|
|
|
|
|
|
RET modify<RET>(RET Function() modify) { |
|
|
|
RET modify<RET>(RET Function() modify) { |
|
|
|
if (_isDirty || _isInModify) { |
|
|
|
if (_isDirty || _isInModify) { |
|
|
|
|
|
|
|
try { |
|
|
|
return modify(); |
|
|
|
return modify(); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
onAfterAnyModify(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
_isInModify = true; |
|
|
|
_isInModify = true; |
|
|
|
onBeforeModify(); |
|
|
|
onBeforeModify(); |
|
|
@ -66,6 +75,7 @@ mixin Changeable<T> { |
|
|
|
_isDirty = true; |
|
|
|
_isDirty = true; |
|
|
|
_isInModify = false; |
|
|
|
_isInModify = false; |
|
|
|
onAfterModify(); |
|
|
|
onAfterModify(); |
|
|
|
|
|
|
|
onAfterAnyModify(); |
|
|
|
_controller.add(ChangeEvent(object: this as T, isDirty: _isDirty)); |
|
|
|
_controller.add(ChangeEvent(object: this as T, isDirty: _isDirty)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -194,9 +204,17 @@ abstract class KdbxObject extends KdbxNode { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @override |
|
|
|
|
|
|
|
// void onAfterModify() { |
|
|
|
|
|
|
|
// super.onAfterModify(); |
|
|
|
|
|
|
|
// times.modifiedNow(); |
|
|
|
|
|
|
|
// // during initial `create` the file will be null. |
|
|
|
|
|
|
|
// file?.dirtyObject(this); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void onAfterModify() { |
|
|
|
void onAfterAnyModify() { |
|
|
|
super.onAfterModify(); |
|
|
|
super.onAfterAnyModify(); |
|
|
|
times.modifiedNow(); |
|
|
|
times.modifiedNow(); |
|
|
|
// during initial `create` the file will be null. |
|
|
|
// during initial `create` the file will be null. |
|
|
|
file?.dirtyObject(this); |
|
|
|
file?.dirtyObject(this); |
|
|
|