We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 77ef32f commit 3bef667Copy full SHA for 3bef667
docs/source/examples/Widget Events.ipynb
@@ -391,14 +391,14 @@
391
" execution until after `wait` seconds\n",
392
" have elapsed since the last time it was invoked. \"\"\"\n",
393
" def decorator(fn):\n",
394
+ " timer = None\n",
395
" def debounced(*args, **kwargs):\n",
396
+ " nonlocal timer\n",
397
" def call_it():\n",
398
" fn(*args, **kwargs)\n",
- " try:\n",
- " debounced.t.cancel()\n",
399
- " except(AttributeError):\n",
400
- " pass\n",
401
- " debounced.t = Timer(wait, call_it)\n",
+ " if timer is not None:\n",
+ " timer.cancel()\n",
+ " timer = Timer(wait, call_it)\n",
402
" return debounced\n",
403
" return decorator"
404
]
0 commit comments