U
    ê¥¡c¶  ã                   @   s"   d dl Z G dd„ dƒZdd„ ZdS )é    Nc                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTimerc                 C   s    || _ || _t |  ¡ ¡| _d S ©N)Ú_timeoutÚ	_callbackÚasyncioZensure_futureÚ_jobÚ_task)ÚselfÚtimeoutÚcallback© r   ú:/tmp/pip-unpacked-wheel-srr0x9ui/pydeck/widget/debounce.pyÚ__init__   s    zTimer.__init__c                 Ã   s   t  | j¡I d H  |  ¡  d S r   )r   Úsleepr   r   ©r	   r   r   r   r   
   s    z
Timer._jobc                 C   s   | j  ¡  d S r   )r   Úcancelr   r   r   r   r      s    zTimer.cancelN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r      s   r   c                    s   ‡ fdd„}|S )Nc                    s   d ‰‡ ‡‡fdd„}|S )Nc                     s.   ‡ ‡‡fdd„}ˆd k	r ˆ  ¡  tˆ|ƒ‰d S )Nc                      s   ˆˆ ˆŽ d S r   r   r   )ÚargsÚfnÚkwargsr   r   Úcall_it   s    z?debounce.<locals>.decorator.<locals>.debounced.<locals>.call_it)r   r   )r   r   r   )r   ÚtimerÚwait)r   r   r   Ú	debounced   s    z.debounce.<locals>.decorator.<locals>.debouncedr   )r   r   ©r   )r   r   r   Ú	decorator   s    
zdebounce.<locals>.decoratorr   )r   r   r   r   r   Údebounce   s    r   )r   r   r   r   r   r   r   Ú<module>   s   