classCounter:"""Simple counter with signals for state changes."""incremented=Signal[int]()reset=Signal[()]()def__init__(self,initial:int=0)->None:self._value=initialdefincrement(self)->None:"""Increment the counter and emit the incremented signal."""self._value+=1asyncio.create_task(self.incremented.emit(self._value))# noqa: RUF006@propertydefvalue(self)->int:"""Return the current value of the counter."""returnself._value
defincrement(self)->None:"""Increment the counter and emit the incremented signal."""self._value+=1asyncio.create_task(self.incremented.emit(self._value))# noqa: RUF006