changed events
This commit is contained in:
@@ -16,6 +16,7 @@ class HookFunction(Protocol):
|
||||
|
||||
class HookedContainer(ABC, Sized, Iterable[T], Container[T]):
|
||||
_path: MutableSequence[int]
|
||||
_root: MutableMapping[T] | MutableSequence[T] | None = None
|
||||
hook: HookFunction
|
||||
|
||||
def __repr__(self):
|
||||
@@ -36,12 +37,12 @@ class HookedContainer(ABC, Sized, Iterable[T], Container[T]):
|
||||
def __setitem__(self, s, value):
|
||||
self._data[s] = value
|
||||
if self.hook:
|
||||
self.hook(e.SetItemEvent(index=s, item=value, path=self._path))
|
||||
self.hook(e.SetItemEvent(self.new_path(s), value))
|
||||
|
||||
def __delitem__(self, s):
|
||||
item = self._data.pop(s)
|
||||
if self.hook:
|
||||
self.hook(e.RemoveItemEvent(index=s, item=item, path=self._path))
|
||||
self.hook(e.RemoveItemEvent(self.new_path(s), item))
|
||||
|
||||
@abstractmethod
|
||||
def insert(self, index, value): ...
|
||||
|
||||
Reference in New Issue
Block a user