Closed BECATRUE closed 1 year ago
I changed the label refactor
-> enhancement
because this provides a new feature which is similar to syntax sugars.
When we say "refactoring", it usually does not change the code behavior (API).
I just implemented the above three methods in BaseApp
.
Before applying it into all apps, please confirm these methods.
It can be checked in BECATRUE/133/simplify-handle-signals
branch.
@kangz12345
Oh, I found that we shouldn't check if the content
is instance of str
in broadcast()
, because it is JSON-loaded when received anyway. I updated the example code above.
In addition my reviews:
pyqtSlot
rather than pyqtSignal
.__init__()
, you should connect _recevedMessage()
to received
signal.@BECATRUE
Oh, I found that we shouldn't check if the
content
is instance ofstr
inbroadcast()
, because it is JSON-loaded when received anyway. I updated the example code above.
I didn't know at all, too😂
Feature you want to implement
Currently the apps emits signals and connects slots to broadcast or to receive broadcast messages. This style is not so intuitive nor convenient.
Therefore, we want to provide an easy way to broadcast and receive messages.
How the feature is implemented
Basically
BaseApp
class will be modified.1. Broadcasting
Implement a simple 'wrapper' method as follows:
2. Receiving
Implement a pre-connected slot as follows:
A child class which inherits
BaseApp
will then overridereceivedSlot()
to handle the received messages. Note that the class can still implement its own slots forreceived
signal. We just provide a new convenient way in addition to the previous method.