Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class Transient<T> {
  2. T _value;
  3.  
  4. Transient(T value) {
  5. this._value = value;
  6. }
  7.  
  8. void use(Function(T value) block) {
  9. assert(block != null);
  10. if (_value != null) {
  11. block(_value);
  12. _value = null;
  13. }
  14. }
  15. }
  16.  
  17. class Event {
  18. Object _flag = Object();
  19.  
  20. void consume(Function block) {
  21. assert(block != null);
  22. if (_flag != null) {
  23. block();
  24. _flag = null;
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement