•  
      request #32632 getAllJSON should have default collection type parameter
    Infos
    #32632
    Joris MASSON (jmasson)
    2023-06-22 17:24
    2023-06-21 17:35
    34222
    Details
    getAllJSON should have default collection type parameter

    getAllJSON() is very useful to retrieve a bunch of paginated JSON objects, but it has an annoying requirement: we always need to define two generic Type parameters, the first one for the type of item we expect to get as an array TypeOfArrayItem, and the second one TypeOfJSONPayload for the shape of the JSON payload we expect to get from the endpoint. Most of the time, TypeOfJSONPayload is really ReadonlyArray<TypeOfArrayItem>. Thus, we should provide this as a default value for this type parameter. It would save developers the trouble of figuring out which parameter goes where: they want an array of TypeOfArrayItem, they just give this and are done. When they are dealing with a special REST endpoint that returns an object, they can provide the second generic type parameter at the same time as the getCollectionCallback option.

    Dev tools
    Empty
    Empty
    • [ ] enhancement
    • [ ] internal improvement
    Empty
    Stage
    Joris MASSON (jmasson)
    Closed
    2023-06-22
    Attachments
    Empty
    References

    Follow-ups