I have an application which sends and receives commands to and from an external device.
I have modeled the interactions with the device as “usecases / interactors” which only do one thing, for example
StartSomething interactor sends the relevant command to the device and then waits for an acknowledgement from the device.
The application can also subscribe to an event bus to receive messages being pushed from the device.
After starting a certain process I expect certain messages to be sent from the device and I thus start listening for them on the event bus. (For example,
I also need to be able to stop the process, either manually or when certain criteria has been met.
Currently I have modeled this as a
SomethingOperation with methods that call the specific interactors (eg
SomethingOperation will also run the logic to check if the operation should be stopped automatically.
SomethingOperation also takes a callback which is implemented by whichever class is using the operation,
SomethingOperationCallback with methods:
So in summary an
operation in my app is something which runs in the background, can be started, can be stopped, can post status updates and can return a result.
My question is the following:
Is there an established pattern with proper terminology and naming conventions for what I am trying to do, or is calling this type of object an
operation sufficient? Apologies if my question is too specific, I would appreciate pointers in the right direction.
Side note: The app runs on Android. Interactors use RxJava to send commands to a BLE device.
Interacting with the
Operation object only requires the app to implement the callback and not worry about the implementation details of the interactors (eg RxJava).