Skip to content

Factory Contextvars

bevy.factory_contextvars.ContextVarDefaultFactory

ContextVarDefaultFactory(name: str, *, default: Callable[[], _T])

Bases: Generic[_T]

This contextvar wrapper uses a factory function to create the value of the context variable if it isn't already set.

name property

name: str

Proxy the name of the contextvar.

get

get() -> _T | None

Proxy getting the value of the contextvar, setting the contextvar's value using the factory function if the contextvar is not already set.

reset

reset(token: _Token[_T]) -> None

Proxy the contextvar's reset method.

set

set(value: _T)

Proxy the contextvar's set method.