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

Bloc has hard-coded dependency on concrete use case type #18

Open
dalewking opened this issue Dec 22, 2019 · 2 comments
Open

Bloc has hard-coded dependency on concrete use case type #18

dalewking opened this issue Dec 22, 2019 · 2 comments

Comments

@dalewking
Copy link

You have this:

class NumberTriviaBloc extends Bloc<NumberTriviaEvent, NumberTriviaState> {
  final GetConcreteNumberTrivia getConcreteNumberTrivia;
  final GetRandomNumberTrivia getRandomNumberTrivia;

Which is hardcoding a dependency on GetConcreteNumberTrivia and GetRandomNumberTrivia types.

Shouldn't that really be:

class NumberTriviaBloc extends Bloc<NumberTriviaEvent, NumberTriviaState> {
  final UseCase<NumberTrivia, Params> getConcreteNumberTrivia;
  final UseCase<NumberTrivia, NoParams> getRandomNumberTrivia;

where Params would be a type (probably better named) in entities or better yet just use int instead and make GetConcreteNumberTrivia implement UseCase<NumberTrivia, int>

@DanielSoCra
Copy link

Imho, the UseCase itself is an abstraction, so there is no need to abstract it again.

@dalewking
Copy link
Author

It isn't as problematic as it would be in Java where you don't have implicit interfaces, but any time you can reduce dependencies it is a good thing.

I am not saying that an abstraction needs to be created. The UseCase abstraction already exists and I am just suggesting that the existing abstraction is used instead of the concrete class. The only issue then is where Params is declared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants