Skip to content

Documentation: Using custom state class does not update state? #1111

@arossi07

Description

@arossi07

Hi, using the example from the docs on how to use custom state does not increment the value:

from starlite import Starlite, State, get


class MyState(State):
    count: int = 0

    def increment(self) -> None:
        self.count += 1


@get("/")
def handler(state: MyState) -> dict:
    state.increment()
    return state.dict()


app = Starlite(route_handlers=[handler])

What am I missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions