Reginald Louis
03/29/2024, 1:49 PMfun jsLocalStorageGetItem(key: String): String =
js("window.localStorage.getItem(key)")
If the key exist, no problem. If the key doesn't exist I have a NullPointerException
on the browser console. I've try to add a String?
as a return type
fun jsLocalStorageGetItem(key: String): String? =
js("window.localStorage.getItem(key)")
But the compiler refuse this solution. Maybe I can get away with a try/catch (didn't try yet) but it seem odd to me we can't handle null value from calling js function...Reginald Louis
03/29/2024, 1:50 PMRobert Jaros
03/29/2024, 2:04 PMRobert Jaros
03/29/2024, 2:04 PMRobert Jaros
03/29/2024, 2:05 PMReginald Louis
03/29/2024, 2:58 PM