I
I
isabsent2019-01-27 15:19:01
Kotlin
isabsent, 2019-01-27 15:19:01

Does the Kotlin example code just seem strange to me?

I'm switching to Kotlin. I understand an example .
I see two classes - the second wraps the first.

package com.sample.marvelgallery.data.network.dto
class DataContainer<T> {
var results: T? = null
}

package com.sample.marvelgallery.data.network.dto
class DataWrapper<T> {
var data: DataContainer<T>? = null
}

Смысл этого оборачивания мне абсолютно непонятен. Кто-нибудь может пояснить?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Tomilov, 2019-03-11
@scraplesh

Most likely, there is an agreement to use an envelope for data to interact with the backend, i.e. directly requested data is stored under the data key . Such an envelope can be useful in situations where you need to standardize the data structure for successful and unsuccessful responses.
So, for example, the data is wrapped in the JSON:API protocol .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question