You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
abstractclassIMyService {
MyServiceMyMethodResultmyMethod();
... more methods
}
sealedclassMyServiceMyMethodResult {
data classMyServiceMyMethodSuccess(Object returnValue);
sealedclassMyServiceMyMethodFailure {
data classMyServiceMyMethodFailureA({String? someProp);
data classMyServiceMyMethodFailureB({requiredint someOtherProp});
finalclassMyServiceMyMethodFailureC();
... more failure cases
}
}
... more method results
// Failures that are shared across multiple methods (This is only an idea -> sharing failures might be bit overkill)finalclassMyServiceMySharedFailureAimplementsMyServiceMyMethodFailure/* more method failure impls go here to get exhaustive switch */{}
... more shared failures
This needs data classes and nested sealed classes to be added to the dart language to be an improvement. Currently freezed does not support nesting unions so we stick with Either and freezed sealed & union classes for now
jtdLab
changed the title
refactor: rm dartz dependency in templates
refactor: service return values + failure definition
May 18, 2023
jtdLab
changed the title
refactor: service return values + failure definition
refactor: Improve service return values + failure definition
May 18, 2023
Instead of Either<FooFailure, FooValue> + a freezed FooFailure Union consider using a sealed class FooResult having success and failure subclasses.
The text was updated successfully, but these errors were encountered: