Skip to content

Instantly share code, notes, and snippets.

@PreyeaRegmi
Created September 8, 2021 11:39
Show Gist options
  • Save PreyeaRegmi/743889d96e74fde19141edd0e7b3f2c5 to your computer and use it in GitHub Desktop.
Save PreyeaRegmi/743889d96e74fde19141edd0e7b3f2c5 to your computer and use it in GitHub Desktop.
class LoanDetailResponse {
final String _emi;
LoanDetailResponse(this._emi);
static from(EMICalculator emiCalculator) {
return LoanDetailResponse(emiCalculator.calculateEMI().toString());
}
}
class FetchLoanDetail extends UseCase<LoanParamRequest, LoanDetailResponse> {
final ILoanRepository _loanRepository;
FetchLoanDetail(this._loanRepository);
@override
Stream<LoanDetailResponse> buildUseCase(LoanParamRequest param) {
return _loanRepository
.getLoanFromServer(param.amount, param.time)
.asStream()
.map((loanDetailDTO) => LoanDetailResponse.from(EMICalculator(param.amount,loanDetailDTO._rate,param.time)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment