Register a callback that will be triggered when this option changes
(self, handler: Callable[[_O], None])
| 73 | self.unset() |
| 74 | |
| 75 | def subscribe(self, handler: Callable[[_O], None]) -> Callable[[_O], None]: |
| 76 | """Register a callback that will be triggered when this option changes""" |
| 77 | if not self.mutable: |
| 78 | msg = "Immutable options cannot be subscribed to." |
| 79 | raise TypeError(msg) |
| 80 | self._subscribers.append(handler) |
| 81 | handler(self.current) |
| 82 | return handler |
| 83 | |
| 84 | def is_set(self) -> bool: |
| 85 | """Whether this option has a value other than its default.""" |
no outgoing calls