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

12
LINES

< > BotCompany Repo | #1015555 // mapLiveValue - apply function to LiveValue

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5820L/32K).

static <A, B> LiveValue<B> mapLiveValue(final F1<A, B> f, final Class<B> type, final LiveValue<A> lv) {
  ret new LiveValue<B>() {
    public Class<B> getType() { ret type; }
    public B get() { ret callF(f, lv!); }
    public LiveValue<B> onChange(Runnable l) { lv.onChange(l); this; }
    public LiveValue<B> removeChangeListener(Runnable l) { lv.removeChangeListener(l); this; }
  };
}

static <A, B> LiveValue<B> mapLiveValue(LiveValue<A> lv, Class<B> type, F1<A, B> f) {
  ret mapLiveValue(f, type, lv);
}

Author comment

Began life as a copy of #1015554

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: #1015555
Snippet name: mapLiveValue - apply function to LiveValue
Eternal ID of this version: #1015555/7
Text MD5: 7f85a7f2e23aaaf6b53acd5c76e9a11b
Transpilation MD5: 2f09db5c78f053a0c4723a6bb885ad6f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-12 19:49:27
Source code size: 522 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 376 / 465
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1015556 - SimpleLiveValue
#1020939 - mapLiveValue_f0 - apply function to LiveValue where function doesn't need the value