feat/architecture/make_usecases_more_modular_and_adaptable #39
| @ -43,23 +43,20 @@ abstract class UseCase<Parameters, ReturnType> | |||||||
|   /// Supports the result of the main scenario and integrates |   /// Supports the result of the main scenario and integrates | ||||||
|   /// some alternative scenarios if necessary. |   /// some alternative scenarios if necessary. | ||||||
|   @override |   @override | ||||||
|   FutureOrResult<ReturnType> execute(Parameters? parameters) => |   FutureOrResult<ReturnType> execute(Parameters? parameters) async { | ||||||
|       Result.tryCatchAsync( |     try { | ||||||
|         () async { |       await onStart(parameters); | ||||||
|           await onStart(parameters); |       final response = await call(parameters); | ||||||
|           final response = await call(parameters); |       if (response.isErr) { | ||||||
|           if (response.isErr) { |         await onError(response.err); | ||||||
|             await onError(response.err); |       } else if (response.isOk && response.ok != null) { | ||||||
|           } else if (response.isOk && response.ok != null) { |         await _onSuccess(response.ok as ReturnType); | ||||||
|             await _onSuccess(response.ok as ReturnType); |       } | ||||||
|           } |       return response; | ||||||
| 
 |     } catch (e) { | ||||||
|           return response.ok!; |       return Err(ClientException(e.toString())); | ||||||
|         }, |     } | ||||||
|         (error) => ClientException( |   } | ||||||
|           error.toString(), |  | ||||||
|         ), |  | ||||||
|       ); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// Abtstract classic usecase. | /// Abtstract classic usecase. | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user