Created
May 27, 2017 20:23
-
-
Save tibastral/8990a5e29cc589e1c1eb11c762459f40 to your computer and use it in GitHub Desktop.
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
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