Skip to content

Instantly share code, notes, and snippets.

@tibastral
Created May 27, 2017 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tibastral/8990a5e29cc589e1c1eb11c762459f40 to your computer and use it in GitHub Desktop.
Save tibastral/8990a5e29cc589e1c1eb11c762459f40 to your computer and use it in GitHub Desktop.
export default function y (elmApp) {
var globalReader = function () {
var reader = new FileReader()
reader.onload = (function (event) {
elmApp.ports.imageRead.send(event.target.result)
})
return reader
}()
elmApp.ports.readImage.subscribe(function (id) {
var node = document.getElementById(id)
if (node === null) {
return
}
globalReader.readAsDataURL(node.files[0])
node.value = ""
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment