# Released under the MIT License. See LICENSE for details.#"""Call related functionality shared between all efro components."""from__future__importannotations# import functoolsfromtypingimportTYPE_CHECKING,TypeVar,GenericT=TypeVar('T')ifTYPE_CHECKING:pass
[docs]classSimpleCallbackSet(Generic[T]):"""A simple way to manage a set of callbacks."""def__init__(self)->None:self._entries:list[SimpleCallbackSetEntry[T]]=[]
[docs]defadd(self,call:T)->None:"""Add a callback."""self._entries.append(SimpleCallbackSetEntry(call))
[docs]defgetcalls(self)->list[T]:"""Return the current set of registered calls."""return[e.callforeinself._entries]
[docs]classSimpleCallbackSetEntry(Generic[T]):"""An entry for a callback set."""def__init__(self,call:T)->None:self.call=call