And/or define a singleton decorator for use on our own class implementations
def singleton(cls):
"""A decorator function to make a class a Singleton"""
instances = {}
def wrapper(*args, **kwargs):
if cls not in instances:
instances[cls] = cls(*args, **kwargs)
return instances[cls]
return wrapper
@singleton
class PluginManager:
...
@sjefferson99 any input on this at all would be appreciated. Any good design patterns? The slack app by default uses decorator registration for the event hooks
Interesting to see how the app would differ without dependency injection.
My Initial Ideas
Would need to add factory functions for all injectables e.g.
And/or define a singleton decorator for use on our own class implementations