xsahil03x / super_enum

Create super-powered dart enums similar to sealed classes in Kotlin
https://pub.dev/packages/super_enum
MIT License
116 stars 13 forks source link

emit `when` method arguments for "empty" actions #52

Closed ened closed 4 years ago

ened commented 4 years ago

Given I have a super_enum definition like this:

@superEnum
enum _ContactUsAction {
  CallPhone,
  StartLiveChat
}

Then the generated when method looks like this:

  R when<R>(
      {@required
          FutureOr<R> Function(CallPhone) callPhone,
      @required
          FutureOr<R> Function(StartLiveChat) startLiveChat}) {

...

could this possibly be simplified to:

  R when<R>(
      {@required
          FutureOr<R> Function() callPhone,
      @required
          FutureOr<R> Function() startLiveChat}) {

...

As from my point of view, the event has no associated values and thus does not need to be passed into the when method.

xsahil03x commented 4 years ago

Yes, it can be done. @astralstriker what are your views on this?

astralstriker commented 4 years ago

@ened @xsahil03x yes looks redundant to me too, we should remove them.