const ref for everyone

This commit is contained in:
Mm2PL 2022-09-17 00:06:39 +02:00
parent 10f771c634
commit 5ea07c5d47
No known key found for this signature in database
GPG key ID: 94AC9B80EFA15ED9

View file

@ -55,9 +55,10 @@ public:
*/ */
explicit APIRequest( explicit APIRequest(
QUrl url, NetworkRequestType requestType, QUrl url, NetworkRequestType requestType,
std::function<OkType(NetworkResult)> successTransformer, const std::function<OkType(NetworkResult)> &successTransformer,
std::function<ErrorType(NetworkResult)> errorTransformer = nullptr, const std::function<ErrorType(NetworkResult)> &errorTransformer =
std::function<void()> onFinally = nullptr) nullptr,
const std::function<void()> &onFinally = nullptr)
: underlying_(std::move(url), requestType) : underlying_(std::move(url), requestType)
, data_(std::make_shared<APIRequestData<OkType, ErrorType>>()) , data_(std::make_shared<APIRequestData<OkType, ErrorType>>())
{ {
@ -97,19 +98,19 @@ public:
return std::move(*this); return std::move(*this);
} }
APIRequest<OkType, ErrorType> onError(APIErrorCallback cb) && APIRequest<OkType, ErrorType> onError(const APIErrorCallback &cb) &&
{ {
this->data_->onError = cb; this->data_->onError = cb;
return std::move(*this); return std::move(*this);
}; };
APIRequest<OkType, ErrorType> onSuccess(APISuceessCallback cb) && APIRequest<OkType, ErrorType> onSuccess(const APISuceessCallback &cb) &&
{ {
this->data_->onSuccess = cb; this->data_->onSuccess = cb;
return std::move(*this); return std::move(*this);
}; };
APIRequest<OkType, ErrorType> finally(APIFinallyCallback cb) && APIRequest<OkType, ErrorType> finally(const APIFinallyCallback &cb) &&
{ {
this->data_->finally = cb; this->data_->finally = cb;
return std::move(*this); return std::move(*this);