ステートフルおじさん用のvdomを使ったフレームワーク作成中。その使用コードの一部
async function chooseFile(){ | |
const ev = await F.on('#chooser', 'change'); | |
const files = Array.prototype.slice.call(ev.target.files, 0); | |
const imageFiles = files.filter((f)=>f.type.match('image.*')); | |
if(imageFiles.length !== 0) { | |
const imagePromises = imageFiles.map(readAsDataURL); | |
const images = (await Promise.all(imagePromises)).map((i)=>i.target.result); | |
const names = imageFiles.map(f=>f.name); | |
const imageData = _.zip(images, names).map(([data,name])=> { | |
return {data, name} | |
}); | |
return actions.appendImage(imageData); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment