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()
Nikky
02/01/2021, 8:53 AMHampus Londögård
02/01/2021, 9:11 AMchanges
.map { doSomethingWith(domNode.value) }
.watch()
Nikky
02/01/2021, 10:09 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.update
Hampus Londögård
02/01/2021, 10:28 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 onload
FileReader
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