Skip to content

Commit 9c721dd

Browse files
committed
ref(signal): use DOMNode type instead of MessagePump for subscribing
When publishing the signal requires a `_pruning` attribute in order to check if the node is not currently getting removed. The attribute is implemented in `DOMNode` and not `MessagePump`.
1 parent 87d0cd7 commit 9c721dd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/textual/signal.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
if TYPE_CHECKING:
2020
from textual.dom import DOMNode
21-
from textual.message_pump import MessagePump
21+
2222
SignalT = TypeVar("SignalT")
2323

2424
SignalCallbackType = Union[
@@ -43,9 +43,9 @@ def __init__(self, owner: DOMNode, name: str) -> None:
4343
"""
4444
self._owner = ref(owner)
4545
self._name = name
46-
self._subscriptions: WeakKeyDictionary[
47-
MessagePump, list[SignalCallbackType]
48-
] = WeakKeyDictionary()
46+
self._subscriptions: WeakKeyDictionary[DOMNode, list[SignalCallbackType]] = (
47+
WeakKeyDictionary()
48+
)
4949

5050
def __rich_repr__(self) -> rich.repr.Result:
5151
yield "owner", self.owner
@@ -59,7 +59,7 @@ def owner(self) -> DOMNode | None:
5959

6060
def subscribe(
6161
self,
62-
node: MessagePump,
62+
node: DOMNode,
6363
callback: SignalCallbackType,
6464
immediate: bool = False,
6565
) -> None:
@@ -97,7 +97,7 @@ def signal_callback(data: object) -> None:
9797
callbacks = self._subscriptions.setdefault(node, [])
9898
callbacks.append(signal_callback)
9999

100-
def unsubscribe(self, node: MessagePump) -> None:
100+
def unsubscribe(self, node: DOMNode) -> None:
101101
"""Unsubscribe a node from this signal.
102102
103103
Args:

0 commit comments

Comments
 (0)