DoLaterHandler.cpp 420 B

1234567891011121314151617181920212223242526
  1. #include "DoLaterHandler.h"
  2. DoLaterHandler::DoLaterHandler()
  3. {
  4. action = []() {};
  5. }
  6. DoLaterHandler::~DoLaterHandler()
  7. {
  8. action();
  9. }
  10. void DoLaterHandler::addTodo(std::function<void()> newAction)
  11. {
  12. std::function<void()> oldAction = action;
  13. this->action = [oldAction, newAction]() {
  14. oldAction();
  15. newAction();
  16. };
  17. }
  18. void DoLaterHandler::execute()
  19. {
  20. action();
  21. action = []() {};
  22. }