Skip to content

Extended Lifespan to Module classes - #100

Merged
eadwinCode merged 4 commits into
mainfrom
ellar_life_span_wrapper
Jun 7, 2023
Merged

Extended Lifespan to Module classes#100
eadwinCode merged 4 commits into
mainfrom
ellar_life_span_wrapper

Conversation

@eadwinCode

@eadwinCode eadwinCode commented Jun 7, 2023

Copy link
Copy Markdown
Collaborator

Whats new

  • @Module() decorated class can extend IApplicationStartup or IApplicationShutdown to implement extra actions during on_startup or on_shutdown respectively.
from ellar.common import IApplicationShutdown, IApplicationStartup, Module
from ellar.core import App

@Module()
class OnStartupModule(IApplicationStartup):
    def __init__(self):
        self.on_startup_called = False

    async def on_startup(self, app: App) -> None:
        self.on_startup_called = True


@Module()
class OnShutdownModule(IApplicationShutdown):
    def __init__(self):
        self.on_shutdown_called = False

    async def on_shutdown(self) -> None:
        self.on_shutdown_called = True

@eadwinCode
eadwinCode merged commit dce02ec into main Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant