Nikky
01/27/2021, 4:50 PM<input type="file"> or so.. but i am not sure how to attach event listeners in fritz2.. and i feel like i am going down the wrong pathHampus LondögÄrd
01/31/2021, 10:59 AMchanges.map { event }.watch()Hampus LondögÄrd
01/31/2021, 11:00 AMNikky
02/01/2021, 8:53 AMHampus LondögÄrd
02/01/2021, 9:11 AMHampus LondögÄrd
02/01/2021, 9:13 AMchanges
.map { doSomethingWith(domNode.value) }
.watch()Nikky
02/01/2021, 10:09 AMNikky
02/01/2021, 10:25 AMchanges.events.map { event: Event ->
val inputElement = event.currentTarget as HTMLInputElement
val files = inputElement.files!!
val file = files[0]!!
console.log("file picked:", file)
file
} handledBy userCsvUploadStore.updateNikky
02/01/2021, 10:25 AMHampus LondögÄrd
02/01/2021, 10:28 AMHampus LondögÄrd
02/01/2021, 10:30 AMinputField(smallTopMargin) {
base {
type("file")
accept("image/*")
changes
.files()
.mapNotNull { value: FileList? -> value?.get(0) }
.onEach { file -> fileReader.readAsDataURL(file) }
.watch()
}
}
This is also null-safe compared to your !! approach đ
My fileReader is a normal FileReader which works async, so I've attached a handler on its onloadHampus LondögÄrd
02/01/2021, 10:39 AMFileReader for me was not really nice, as overloading onload is very much like touching JS-code without nice wrappers into a Flow. Do you know how to do that smoothly?Jan Weidenhaupt
03/02/2021, 6:14 PM