flarum / issue-archive

0 stars 0 forks source link

JS/Frontend app.store multi response sets should be collections #5

Open luceos opened 2 years ago

luceos commented 2 years ago

Feature Request

It would be great if we can make result sets collections. So that we not just get an array of objects, but also their respective meta data and possible helper functions.

Is your feature request related to a problem? Please describe.

The problem right now is that if you return meta information like pagination counts etc, this information is dropped while pulling objects from the store.

Describe the solution you'd like It would be cool pushing the data into a collection that also supports meta information.

Justify why this feature belongs in Flarum's core, rather than in a third-party extension

Only core has a store and handles the api requests using app.request.

askvortsov1 commented 2 years ago

The find method currently returns an ApiResponse instance, which includes payload information. See https://github.com/flarum/core/blob/59dc3c26223350c8f96b78b896478d16e3be327a/js/src/common/Store.ts#L167-L167

I'm not sure how we could effectively store this in the store itself though. It would be a memory leak, as we would need to store this metadata for each request, and it's not clear when the data for any given request should be evicted.