When implementing subscriptions to IMC messages, one often has to filter the incoming messages based on some criteria. E.g. if the message are coming from a specific system, or is being sent to a target system, or that the actor is in a certain state
One proposed quality of life improvement wrt. this is the addition of a filtering input to the subscription decorator itself. Usage would look as follows
class TestActor(IMCBase):
@Subscribe(pyimc.EstimatedState)
def without_filter(self, msg):
if msg.src == 0x5501:
# Do stuff
...
def filter(self, msg):
return msg.src == 0x5501
@Subscribe(pyimc.EstimatedState, filter=TestActor.filter)
def with_filter(self, msg):
# Do stuff immediately
When implementing subscriptions to IMC messages, one often has to filter the incoming messages based on some criteria. E.g. if the message are coming from a specific system, or is being sent to a target system, or that the actor is in a certain state
One proposed quality of life improvement wrt. this is the addition of a filtering input to the subscription decorator itself. Usage would look as follows