Created
May 29, 2018 06:13
-
-
Save gdotdesign/a0e203b6fc64ed1c9a646c5c27fe31af to your computer and use it in GitHub Desktop.
BarcodeScanner.mint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum BarcodeScanner.Error { | |
Unkown | |
} | |
module BarcodeScanner { | |
fun scan : Promise(BarcodeScanner.Error, String) { | |
` | |
new Promise((resolve, reject) => { | |
cordova.plugins.barcodeScanner.scan((result) => { | |
resolve(result.text) | |
}, (error) => { | |
reject($BarcodeScanner_Error_Unkown) | |
}) | |
}) | |
` | |
} | |
} | |
component Main { | |
fun handleClick (event : Html.Event) : Void { | |
do { | |
result = | |
BarcodeScanner.scan() | |
Debug.log(result) | |
} catch BarcodeScanner.Error => error { | |
Debug.log(error) | |
} | |
} | |
fun render : Html { | |
<div onClick={handleClick}> | |
<{ "Scan" }> | |
</div> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment