looking like it is related the the scope I am usin...
# javascript
t
looking like it is related the the scope I am using it in
b
Please provide more info. Ideally, a self-contained example.
maybe compiler diagnostic as is
What is
textContent
and
client
?
t
Copy code
XMLHttpRequest().also { client ->
  client.open("GET", logcatFile)
  client.onreadystatechange = { event ->
    logcatArea.textContent = client.responseText
  }
  client.send()
}
where logcatArea is of type
Element
even if I say
logcatArea.textContent = "foo"
inside that callback it complains the same. just outside and everything is fine. wondering if it is some sort of closure of variable entity type of issue?
looking like the following might do what I need:
Copy code
window.fetch(Request(logcatFile)).then {
  it.text().then {
    logcatArea.textContent = it
  }
}
b
try to write anything in next line
e.g.
Unit
or
null
t
yup that solves it
b
Copy code
window.fetch(Request(logcatFile)).then {
  it.text().then {
    logcatArea.textContent = it
    null
  }
}
t
return of callback expecting something and result of assignment is what void/Nothing?
yes, compiler expected that callback will return anything, but assignment is not expression in Kotlin and compiler doesn’t know where from take a value to return