SHARE
TWEET

Untitled

a guest Jul 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top