Last active
June 25, 2021 17:17
-
-
Save PreyeaRegmi/42a3533efcd6ffa7735d6a8ce250e1ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Usecase Implementation | |
class PostBillingInfoUseCase | |
extends UseCase<BillingInfoRequest, BillingInfoResponse> { | |
final BillingInfoRepository _billingInfoRepository; | |
PostBillingInfoUseCase(this._billingInfoRepository); | |
@override | |
Stream<BillingInfoResponse> buildUseCase(BillingInfoRequest param) { | |
return _billingInfoRepository.postBillingInfo(param).asStream(); | |
} | |
} | |
//Usecase invocation from presentation layer | |
PostBillingInfoUseCase(MockedBillingInfoRepository()) | |
.execute(BillingInfoRequest(), (result) { | |
//TODO Display result | |
}, (errorMessage) { | |
//TODO Display error | |
}); | |
//Usecase implementation | |
class PostShippingInfoUseCase extends UseCase<ShippingInfoRequest, ShippingInfoResponse> { | |
final ShippingInfoRepository _shippingInfoRepository; | |
PostShippingInfoUseCase(this._shippingInfoRepository); | |
@override | |
Stream<ShippingInfoResponse> buildUseCase(ShippingInfoRequest param) { | |
return _shippingInfoRepository.postShippingInfo(param).asStream(); | |
} | |
} | |
//Usecase invocation from presentation layer | |
PostShippingInfoUseCase(MockedShippingInfoRepository()) | |
.execute(ShippingInfoRequest(), (result) { | |
//TODO Display result | |
}, (errorMessage) { | |
//TODO Display result | |
}); | |
//Usecase implementation | |
class PostBillingAndShippingInfoUseCase | |
extends UseCase<BillingShippingInfoRequest, BillingShippinInfoResponse> { | |
final PostBillingInfoUseCase _postBillingInfoUseCase; | |
final PostShippingInfoUseCase _postShippingInfoUseCase; | |
PostBillingAndShippingInfoUseCase( | |
this._postBillingInfoUseCase, this._postShippingInfoUseCase); | |
@override | |
Stream<BillingShippinInfoResponse> buildUseCase( | |
BillingShippingInfoRequest param) { | |
return Rx.zip2( | |
_postBillingInfoUseCase.buildUseCase(param.billingInfoRequest), | |
_postShippingInfoUseCase.buildUseCase(param.shippingInfoRequest), | |
(BillingInfoResponse billingResult, | |
ShippingInfoResponse shippingResult) => | |
BillingShippinInfoResponse.from(billingResult, shippingResult)); | |
} | |
} | |
//Usecase invocation from presentation layer | |
PostBillingAndShippingInfoUseCase(PostBillingInfoUseCase(MockedBillingInfoRepository()),PostShippingInfoUseCase(MockedShippingInfoRepository())) | |
.execute(BillingShippingInfoRequest(BillingInfoRequest(),ShippingInfoRequest()), (result) { | |
//TODO Display result | |
}, (errorMessage) { | |
//TODO Display result | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment