Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unions inheritance #63

Closed
zs-dima opened this issue Feb 24, 2020 · 9 comments
Closed

Unions inheritance #63

zs-dima opened this issue Feb 24, 2020 · 9 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@zs-dima
Copy link

zs-dima commented Feb 24, 2020

It could be nice to use Unions for the BLOC states
But states usually have inheritance:

abstract class AppState {}
abstract class AppNavigationState {}
class AppNavigateToAState extends AppState with AppNavigationState {}
class AppNavigateToBState extends AppState with AppNavigationState {}
class AppSomeOtherState extends AppState {}

so we could filter states after:

.appBloc.whereType<AppNavigationState>()

so it could befreezed freezedWith attribute for example:

abstract class AppNavigationState {}

@freezed
abstract class AppState with _$Union {
  @freezedWith(AppNavigationState)
  const factory AppState.navigateToA() = NavigateToA;
  @freezedWith(AppNavigationState)
  const factory AppState.navigateToB() = NavigateToB;
}
@rrousselGit
Copy link
Owner

And how do you plan on implementing the interface?

@rrousselGit rrousselGit added enhancement New feature or request question Further information is requested labels Feb 24, 2020
@zs-dima
Copy link
Author

zs-dima commented Feb 25, 2020

And how do you plan on implementing the interface?

In the example just AppNavigationState inheritance, to filter out BLOC states by whereType() later

@rrousselGit
Copy link
Owner

rrousselGit commented Feb 25, 2020

That's not what I meant.
If the interface has properties and methods, how will you implement these?

@zs-dima
Copy link
Author

zs-dima commented Feb 27, 2020

If the interface has properties and methods

properties and methods are not usually used for BLOC for the case I described

@rrousselGit rrousselGit mentioned this issue Mar 16, 2020
3 tasks
@rrousselGit
Copy link
Owner

Added as part of 0.11.0

@fernando-s97
Copy link

Is it possible to use something like:

abstract class GenericFailure {}

@freezedWith(GenericFailure)
abstract class SpecificFailure with _$SpecificFailure {
  const factory SpecificFailure.A() = A;
  const factory SpecificFailure.B() = B;
}

@rrousselGit
Copy link
Owner

No, it is not possible

@fernando-s97
Copy link

Thanks!

@petrnymsa
Copy link

Hi, sorry to "reopen" old issue, but how exactly mentioned version 0.11.0 solves this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants