MCPcopy Index your code
hub / github.com/reactive-python/reactpy / subscribe

Method subscribe

src/py/reactpy/reactpy/_option.py:75–82  ·  view source on GitHub ↗

Register a callback that will be triggered when this option changes

(self, handler: Callable[[_O], None])

Source from the content-addressed store, hash-verified

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."""

Callers 3

test_option_subscribeFunction · 0.95
__init__Method · 0.80

Calls

no outgoing calls

Tested by 2

test_option_subscribeFunction · 0.76