Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

21
LINES

< > BotCompany Repo | #1015556 - SimpleLiveValue

JavaX fragment (include)

sclass SimpleLiveValue<A> extends LiveValue<A> {
  Class<A> type;
  volatile A value;
  
  transient L onChange = synchroList();
  
  *(Class<A> *type) {}
  *(Class<A> *type, A *value) {}
  
  public Class<A> getType() { ret type; }
  public A get() { ret value; }
  public void onChange(Runnable l) { onChange.add(l); }
  public void onChangeAndNow(Runnable l) { onChange(l); callF(l); }
  public void removeOnChangeListener(Runnable l) { onChange.remove(l); }
  
  void fireChanged() {
    pcallFAll(onChange);
  }
  
  void set(A a) { if (neq(value, a)) { value = a; fireChanged(); } }
}

Author comment

Began life as a copy of #1015555

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015556
Snippet name: SimpleLiveValue
Eternal ID of this version: #1015556/7
Text MD5: 8caa73d693c5d0f05a42323e03782ab1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-29 19:09:07
Source code size: 610 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 262 / 794
Version history: 6 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1015556 & http://1015556.tinybrain.de