[REQ] [Qt5] Emit a generic signal anytime an api call is completed
See original GitHub issueThe current callback in the API interface emits signals specific to the API, for example
if (worker->error_type == QNetworkReply::NoError) {
emit createUsersWithArrayInputSignal();
emit createUsersWithArrayInputSignalFull(worker);
} else {
emit createUsersWithArrayInputSignalE(error_type, error_str);
emit createUsersWithArrayInputSignalEFull(worker, error_type, error_str);
}
From the outside we can then connect to these signals
The API has different signals per function call.
I would like to be able to know if the API did “any work” not just some “specific work”
For example I would add a signal called void workDone()
if (worker->error_type == QNetworkReply::NoError) {
emit createUsersWithArrayInputSignal();
emit createUsersWithArrayInputSignalFull(worker);
} else {
emit createUsersWithArrayInputSignalE(error_type, error_str);
emit createUsersWithArrayInputSignalEFull(worker, error_type, error_str);
}
emit workDone();
if (worker->error_type == QNetworkReply::NoError) {
emit createUsersWithListInputSignal();
emit createUsersWithListInputSignalFull(worker);
} else {
emit createUsersWithListInputSignalE(error_type, error_str);
emit createUsersWithListInputSignalEFull(worker, error_type, error_str);
}
emit workDone();
and this would be added to ALL of the callback functions. From the outside then we could connect to know if the API class has done anything yet without needing to connect to a whole bunch of individual signals
This would be trivial for me to add so I wanted to open it up for discussion before just adding a PR
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
Signals & Slots | Qt Core 6.4.1
A signal is emitted when a particular event occurs. Qt's widgets have many predefined signals, but we can always subclass widgets to add...
Read more >QThread emits finished() signal but isRunning() returns true ...
The function locateMe() is called whenever a button is clicked. The first time when the thread isnt started and the button is clicked...
Read more >Transmit extra data with signals in PyQt5 - Python GUIs
The triggered signal emits a single piece of data -- the checked state ... SIGNAL: The connected function will be called whenever the...
Read more >Understanding the mechanism of signals and slots | Qt 5 ...
Since Qt uses a mechanism called signals and slots, it makes the callback function weakly coupled to the event. Also, we usually use...
Read more >qnetworkreply.cpp source code [qtbase/src/network/access ...
82, network and processed, the readyRead() signal is emitted. ... 187, \value ContentConflictError the request could not be completed due.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That is right, so whenever any worker is destroyed we check in the
lambda
ifthis
which is the API object has any worker remaining. When all workers are destroyed (triggered by abort, timeout and network responses) the current API object will have no more workers and therefore no more active request.OK thank you for elaborating the use case. What I was trying to say is that, using your example
In the above case, It is unknown whether signal
callbackExecutedSignal()
comes fromdeletePet()
oraddPet()
. Maybe not an issue in this case since you only care if the call was completed. But if we were to make a feature we should handle the case where we have to emit the signal when all pending request from that object have been done or timed out.