design-patterns/behavioral/command/main.py
Ruidy c8cc1f47b8
Observer (#20)
* doc: create package & update general TOCs

* doc: add documentation

* add code example

* reformat using black
2020-10-06 08:25:18 +02:00

15 lines
485 B
Python

"""
The client code can parameterize an invoker with any commands.
"""
from behavioral.command.commands import SimpleCommand, ComplexCommand
from behavioral.command.invoker import Invoker
from behavioral.command.receiver import Receiver
if __name__ == "__main__":
invoker = Invoker()
invoker.set_on_start(SimpleCommand("Say hi"))
receiver = Receiver()
invoker.set_on_finish(ComplexCommand(receiver, "Send email", "Save report"))
invoker.do_something_important()