Subscribing to reactive variable changes

I see there are subscribe and subscribe_change methods on Reactive, but I don't see how best to use them and what is the difference between them? If I wanted to e.g. trigger validation on value input, what should I use?
1 Reply
MaartenBreddels
MaartenBreddels10mo ago
we should add docstrings, but def subscribe(self, listener: Callable[[T], None], scope: Optional[ContextManager] = None): gives a hint, it will trigger your callback with the latest value def subscribe_change(self, listener: Callable[[T, T], None], scope: Optional[ContextManager] = None): -- there the callback takes 2 arguments, the new and old value Note that you can only do a subscribe from a component, or other context where you know you are in a kernel context. For instance, if you do this top level in a module, it will not work.
Want results from more Discord servers?
Add your server