Skip to content

Instantly share code, notes, and snippets.

@tomaspietravallo
Last active August 8, 2020 17:08
Show Gist options
  • Save tomaspietravallo/0aca28203bbaf1c0f1d83f4d749b9ae6 to your computer and use it in GitHub Desktop.
Save tomaspietravallo/0aca28203bbaf1c0f1d83f4d749b9ae6 to your computer and use it in GitHub Desktop.
onPan & onLongPress seem to be broken (? or my code is ¯\_(ツ)_/¯
let x, y;
TouchGestures.onLongPress().subscribe((event)=>{
event.location.x.monitor({fireOnInitialValue: true}).subscribe((v)=>{
x = v.newValue;
});
event.location.y.monitor({fireOnInitialValue: true}).subscribe((v)=>{
y = v.newValue;
Diagnostics.log(`Gesture: onLongPress \t| X: ${x}, Y: ${y}`);
});
});
let x1, y1;
TouchGestures.onPan().subscribe((event)=>{
event.location.x.monitor({fireOnInitialValue: true}).subscribe((v)=>{
x1 = v.newValue;
});
event.location.y.monitor({fireOnInitialValue: true}).subscribe((v)=>{
y1 = v.newValue;
Diagnostics.log(`Gesture: onPan \t| X: ${x1}, Y: ${y1}`);
});
});
@tomaspietravallo
Copy link
Author

tomaspietravallo commented Aug 8, 2020

function checkAndPack2(x, y, defaultValue){
    let values = [x, y];
    values.map(x => x || R.val(defaultValue));
    return R.pack2(values[0], values[1]);
};

I ended up using the function above to pack the values and check for any undefined, but this is the same function I had had some issues with. I also learned about R.monitorMany which made the code much cleaner - similar to yours @pofulu, thanks for the help ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment