3
ˆd  ã               @   sB   d dl mZ d dlmZ dd„ Zdedœdd„Zdd	œd
d„ZdS )é    )Úadd_or_remove_notifiers)Úcompile_exprc             C   s   | |ƒ dS )aW   Dispatch an event handler on the same thread.

    Parameters
    ----------
    handler : callable(event)
        User-defined callable to handle change events.
        ``event`` is an object representing the change.
        Its type and content depends on the change.
    event : object
        The event object to be given to handler.
    N© )ÚhandlerÚeventr   r   ú</tmp/pip-build-7vycvbft/traits/traits/observation/observe.pyÚdispatch_same   s    r   F)ÚremoveÚ
dispatcherc            C   s   t | t|ƒ|||d dS )a   Observer or unobserve traits on an object.

    Parameters
    ----------
    object : object
        An object to be observed. Usually an instance of ``HasTraits``.
    expression : ObserverExpression
        An object describing what traits are being observed.
    handler : callable(event)
        User-defined callable to handle change events.
        ``event`` is an object representing the change.
        Its type and content depends on the change.
    remove : boolean, optional
        If true, remove notifiers. i.e. unobserve the traits.
    dispatcher : callable(callable, event), optional
        Callable for dispatching the user-defined handler, e.g. dispatching
        callback on a different thread. Default is to dispatch on the same
        thread.
    )Úgraphsr   r
   r	   N)Úapply_observersr   )ÚobjectZ
expressionr   r	   r
   r   r   r   Úobserve   s    r   )r	   c         	   C   s&   x |D ]}t | ||| ||d qW dS )a÷   Apply one or more ObserverGraphs to an object and handler.

    Parameters
    ----------
    object : object
        An object to be observed. Usually an instance of ``HasTraits``.
    graphs : list of ObserverGraph
        Graphs describing the observation patterns to apply.
    handler : callable(event)
        User-defined callable to handle change events.
        ``event`` is an object representing the change.
        Its type and content depends on the change.
    dispatcher : callable(callable, event).
        Callable for dispatching the user-defined handler, e.g. dispatching
        callback on a different thread.
    remove : boolean, optional
        If True, remove notifiers. i.e. unobserve the traits. The default
        is False.
    )r   Úgraphr   Útargetr
   r	   N)r   )r   r   r   r
   r	   r   r   r   r   r   =   s    
r   N)Ztraits.observation._observer   Ztraits.observation.expressionr   r   r   r   r   r   r   r   Ú<module>   s   