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

33
LINES

< > BotCompany Repo | #1026955 // OLD version for persistent fields only. dm_fieldLiveValue - live-value for a field in DynModule

JavaX fragment (include)

static SimpleLiveValue dm_fieldLiveValue(S fieldName) {
  ret dm_fieldLiveValue(dm_current_mandatory(), fieldName);
}

static SimpleLiveValue dm_fieldLiveValue(final DynModule module, fS fieldName) {
  lock module.lock;
  Class type = getFieldType(module, fieldName);
  final SimpleLiveValue value = new(type, get(module, fieldName));
  module.onChange(r {
    ifdef dm_fieldLiveValue_debug
      print("dm_fieldLiveValue: setting " + fieldName);
    endifdef
    O o = get(module, fieldName);
    ifdef dm_fieldLiveValue_debug
      print("dm_fieldLiveValue: setting " + fieldName + " = " + o);
    endifdef
    value.set(o);
    ifdef dm_fieldLiveValue_debug
      print("dm_fieldLiveValue: setting " + fieldName + " done");
      printStackTrace();
    endifdef
  });
  value.onChange(r {
    ifdef dm_fieldLiveValue_debug
      print("dm_fieldLiveValue: setting 2 " + fieldName + " = " + value!);
    endifdef
    module.setField(fieldName, value!);
    ifdef dm_fieldLiveValue_debug
      print("dm_fieldLiveValue: setting 2 " + fieldName + " done");
    endifdef
  });
  ret value;
}

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: #1026955
Snippet name: OLD version for persistent fields only. dm_fieldLiveValue - live-value for a field in DynModule
Eternal ID of this version: #1026955/1
Text MD5: 611c82031d850f75a1562b4b52d042d7
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-02-03 17:58:21
Source code size: 1121 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 193 / 213
Referenced in: [show references]