image icon indicating copy to clipboard operation
image copied to clipboard

Provide generics for Image class

Open dependentmadani opened this issue 1 year ago • 0 comments

Problem

The current design of the Image class doesn't make it easily extendable so that users can define their actions and additional fields in the upload response. This also limits class extensions for use cases where custom data and actions must be implemented.

Cause

The Image class was first designed with types fixed for the actions and upload response data, which is a very concrete design, and it limited the flexibility with different kinds of requirements. The approach taken in designing thus becomes relatively narrow and does not allow an extension of the user's custom properties during the creation of Image object.

Solution

Generic types should be used to re-implement the Image class to fix this problem. The definition of the class should change into class ImageTool<CustomActions = {}, AdditionalUploadResponse = {}>, such that while the object of it is created, users can provide their custom actions and additional upload response types. This makes the Image class flexible and more usable and leaves the ability to respond to almost any scenario and requirements.

dependentmadani avatar Jul 08 '24 14:07 dependentmadani