You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, a user does an operation that triggers a function, but the operation turns out to be invalid, and state is unchanged (at least, as far as a user can tell).
For example, in my application, items can be added in arbitrary positions on a canvas, but they are only valid depending on specific rules. Because I need to loop over a prohibitively large amount of objects, I am reluctant to do a verification pass, then an update pass; I do both at the same time. So the function is what goes in Undo's execute, whether it leads to a meaningful change or not.
In those cases, enabling the undo button is confusing, and pressing it does nothing that the user can see or care about.
None of those changes break any backwards compatibility, and they make things more convenient.
Passing lambdas works, but typed named void functions don't, so it is backward compatibility breaking. dynamic works, I'm not acquainted with Dart enough to know if something else works better.
Then, one could write:
changes.add(Change(
data,
(){
try{
attemptInsertData();
returntrue;
}catch(e){
returnfalse;
}
},
(old) => data = old
));
If you like this change, I can create a PR.
The text was updated successfully, but these errors were encountered:
Sometimes, a user does an operation that triggers a function, but the operation turns out to be invalid, and state is unchanged (at least, as far as a user can tell).
For example, in my application, items can be added in arbitrary positions on a canvas, but they are only valid depending on specific rules. Because I need to loop over a prohibitively large amount of objects, I am reluctant to do a verification pass, then an update pass; I do both at the same time. So the function is what goes in Undo's
execute
, whether it leads to a meaningful change or not.In those cases, enabling the undo button is confusing, and pressing it does nothing that the user can see or care about.
if the line https://github.com/rodydavis/undo/blob/master/lib/src/undo_stack.dart#L20 allowed the following:
Then one could optionally return
false
from the execute function, which would solve my problem.Line https://github.com/rodydavis/undo/blob/master/lib/src/undo_stack.dart#L88 would need to be changed thusly:
None of those changes break any backwards compatibility, and they make things more convenient.Passing lambdas works, but typed named
void
functions don't, so it is backward compatibility breaking.dynamic
works, I'm not acquainted with Dart enough to know if something else works better.Then, one could write:
If you like this change, I can create a PR.
The text was updated successfully, but these errors were encountered: