def get_maintainer(self, graph, handler, target, dispatcher): """ Return a notifier for maintaining downstream observers when a dict is mutated. Parameters ---------- graph : ObserverGraph Description for the *downstream* observers, i.e. excluding self. handler : callable User handler. target : object Object seen by the user as the owner of the observer. dispatcher : callable Callable for dispatching the handler. Returns ------- notifier : ObserverChangeNotifier """ return ObserverChangeNotifier( observer_handler=_observer_change_handler, event_factory=dict_event_factory, prevent_event=lambda event: False, graph=graph, handler=handler, target=target, dispatcher=dispatcher, )
def get_maintainer(self, graph, handler, target, dispatcher): """ Return a notifier for maintaining downstream observers when a trait is changed. All events should be allowed through, including setting default value such that downstream observers can be maintained on the new value. Parameters ---------- graph : ObserverGraph Description for the *downstream* observers, i.e. excluding self. handler : callable User handler. target : object Object seen by the user as the owner of the observer. dispatcher : callable Callable for dispatching the handler. Returns ------- notifier : ObserverChangeNotifier """ return ObserverChangeNotifier( observer_handler=observer_change_handler, event_factory=trait_event_factory, prevent_event=lambda event: False, graph=graph, handler=handler, target=target, dispatcher=dispatcher, )
def create_notifier(**kwargs): """ Convenient function for creating an instance of ObserverChangeNotifier for testing purposes. """ values = dict( graph=mock.Mock(), observer_handler=mock.Mock(), event_factory=mock.Mock(), prevent_event=lambda event: False, handler=mock.Mock(), target=mock.Mock(), dispatcher=dispatch_here, ) values.update(kwargs) return ObserverChangeNotifier(**values)