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

33
LINES

< > BotCompany Repo | #1027315 // dm_fieldLiveValueWithConversions

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

Libraryless. Click here for Pure Java version (10210L/72K).

1  
static <A, B> SimpleLiveValue dm_fieldLiveValueWithConversions(S fieldName, Class<A> type, IF1<B, A> convertFromField, IF1<A, B> convertToField) {
2  
  ret dm_fieldLiveValueWithConversions(dm_current_mandatory(), fieldName, type, convertFromField, convertToField);
3  
}
4  
5  
static <A, B> SimpleLiveValue dm_fieldLiveValueWithConversions(S fieldName, Class<A> type, F1<B, A> convertFromField, F1<A, B> convertToField) {
6  
  ret dm_fieldLiveValueWithConversions(dm_current_mandatory(), fieldName, type, convertFromField, convertToField);
7  
}
8  
9  
static <A, B> SimpleLiveValue dm_fieldLiveValueWithConversions(DynModule module, S fieldName, Class<A> type, IF1<B, A> convertFromField, IF1<A, B> convertToField) {
10  
  lock module.lock;
11  
  temp module.enter(); // for dm_watchField
12  
  SimpleLiveValue<A> value = new(type, convertFromField.get((B) get(module, fieldName)));
13  
  dm_watchField(fieldName, r {
14  
    value.set(convertFromField.get((B) get(module, fieldName)));
15  
  });
16  
  value.onChange(r {
17  
    module.setField(fieldName, convertToField.get(value!));
18  
  });
19  
  ret value;
20  
}
21  
22  
static <A, B> SimpleLiveValue dm_fieldLiveValueWithConversions(DynModule module, S fieldName, Class<A> type, F1<B, A> convertFromField, F1<A, B> convertToField) {
23  
  lock module.lock;
24  
  temp module.enter(); // for dm_watchField
25  
  SimpleLiveValue<A> value = new(type, convertFromField.get((B) get(module, fieldName)));
26  
  dm_watchField(fieldName, r {
27  
    value.set(convertFromField.get((B) get(module, fieldName)));
28  
  });
29  
  value.onChange(r {
30  
    module.setField(fieldName, convertToField.get(value!));
31  
  });
32  
  ret value;
33  
}

Author comment

Began life as a copy of #1015971

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027315
Snippet name: dm_fieldLiveValueWithConversions
Eternal ID of this version: #1027315/6
Text MD5: 37aae8f7fd668acdf44ad92fc1f9d84c
Transpilation MD5: f0b1767ea43f4efaade7b2fba3f1101b
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-02 16:29:04
Source code size: 1604 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 201 / 300
Version history: 5 change(s)
Referenced in: [show references]