Quantcast
Viewing all articles
Browse latest Browse all 81

Are Bloc events the same as Clean Architecture use-cases?

I have this sample code for use cases:

final class AuthUseCases {  final DataProxy dataProxy;  const AuthUseCases(this.dataProxy);  Future<AuthSession> login(TCredential credential) async {    // a lot of lines here...  }  AuthSession logout(AuthSession session) {    // a few lines here...  }}

and I have this sample code for BloC events by using Freezed package:

@freezedsealed class TmdbEvent with _$TmdbEvent {  const factory TmdbEvent.login(TCredential credential) = LoginEvent;  const factory TmdbEvent.logout() = LogoutEvent;}class TmdbBloc extends Bloc<TmdbEvent, PageState> {  // more lines here...}

So I was asking myself if I could join these classes together because I think BloC events are the same as use-cases. So some questions here:

  • is that idea correct?
  • how would this new class look like? I'm new with Freezed package
  • is it a good idea to keep a single class or have them separate?

Viewing all articles
Browse latest Browse all 81

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>