Libraryless. Click here for Pure Java version (10142L/56K).
| 1 | sclass RSTVar<A> extends VarWithNotify<A> {
 | 
| 2 | IVF1<A> action; | 
| 3 | A lastSentValue; | 
| 4 | ReliableSingleThread rst = new(l0 update); | 
| 5 | volatile bool forceUpdate; | 
| 6 | |
| 7 |   *(IVF1<A> *action) {
 | 
| 8 | onChange(rst); | 
| 9 | } | 
| 10 | |
| 11 |   private void update {
 | 
| 12 | A value = get(); | 
| 13 |     if (!eq(lastSentValue, value) || forceUpdate) {
 | 
| 14 | forceUpdate = false; | 
| 15 | lastSentValue = value; | 
| 16 | action?.get(value); | 
| 17 | } | 
| 18 | } | 
| 19 | |
| 20 |   void forceUpdate {
 | 
| 21 | set forceUpdate; | 
| 22 | rst.trigger(); | 
| 23 | } | 
| 24 | } | 
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1035510 | 
| Snippet name: | RSTVar - Variable with action using ReliableSingleThread (e.g. for always showing the latest image of a stream) | 
| Eternal ID of this version: | #1035510/7 | 
| Text MD5: | f2e0b81d0b60c50ab2c94719199c8671 | 
| Transpilation MD5: | 5471df5eab82d36b7fb38835c4b55bdf | 
| Author: | stefan | 
| Category: | javax | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2022-08-20 18:47:53 | 
| Source code size: | 488 bytes / 24 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 592 / 725 | 
| Version history: | 6 change(s) | 
| Referenced in: | [show references] |