In my application service, why should I return ListResultDto
instead of returning List
?
It seems like extra work.
On the frontend, it means I need to access the items
property instead of treating the results as an array e.g.
Using ListResultDto
.subscribe((next) => this.entities = next.items);
Using List
.subscrube((next) => this.entities = next);
Using ListResultDto
allows you to add additional information about your items
in the future without breaking your existing API. If you return items
as an array, you are restricting your API.
An example is TotalCount
in PagedResultDto
, if you want to implement pagination of items
.