Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gdotdesign/a0e203b6fc64ed1c9a646c5c27fe31af to your computer and use it in GitHub Desktop.
Save gdotdesign/a0e203b6fc64ed1c9a646c5c27fe31af to your computer and use it in GitHub Desktop.
BarcodeScanner.mint
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