effect icon indicating copy to clipboard operation
effect copied to clipboard

Simplify `Schema.TaggedRequest` Signature for Better Usability and Readability

Open gcanti opened this issue 1 year ago • 0 comments

What is the problem this feature would solve?

The current signature of Schema.TaggedRequest is difficult to parse, which may lead to confusion and errors in its usage. The syntax for declaring a TaggedRequest involves multiple parameters that can be challenging to understand and maintain.

Current Syntax

Here is the current way TaggedRequest is implemented:

class Sample extends Schema.TaggedRequest<Sample>("Sample")(
  "Sample",
  Schema.String,
  Schema.Number,
  { id: Schema.String, foo: Schema.Number }
) {}

What is the feature you are proposing to solve the problem?

Proposed Changes

To enhance clarity and ease of use, I propose restructuring the TaggedRequest parameters into an object:

class Sample extends Schema.TaggedRequest<Sample>("Sample")(
  "Sample",
  {
    Failure: Schema.String,
    Success: Schema.Number,
    fields: { 
      id: Schema.String, 
      foo: Schema.Number 
    }
  }
) {}

What alternatives have you considered?

No response

gcanti avatar Jul 02 '24 13:07 gcanti