https://kotlinlang.org logo
#http4k
Title
# http4k
r

Razvan

11/10/2020, 10:06 AM
Hi if a declare lens asResult can I pass it the meta or I have to make a lens then a result and pass the lens to the receiving .
d

dave

11/10/2020, 10:33 AM
the description occurs in the API before the conversion to a Result.
Copy code
Query.required("name", "description").asResult()
r

Razvan

11/11/2020, 3:56 AM
Sorry i did not explain myself well. If i got a result:
Copy code
val nameResult = Query.required("name", "description").asResult()
Can I use this in the ContractRoute
meta
Copy code
meta {
  queries += nameResult
}
or do I have to declare apart:
Copy code
val nameLens = Query.required("name", "description")
val nameResult = nameLens.asResult()

neta {
   queries += nameLens
}
So the question is can I only declare the result then is possible to pass it in the meta or a way to get from the result the Lens to avoid using the double declaration of variables.
d

dave

11/11/2020, 6:28 AM
Ah - no you can’t. Sorry. You can however just create the base lens and then call asResult() on it after you’ve put it into the meta block. Or call it every time before you extract.
r

Razvan

11/11/2020, 10:16 AM
Ok thanks
2 Views