Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyaboulton committed Mar 28, 2024
1 parent 6ee02eb commit 6aec8fe
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
5 changes: 1 addition & 4 deletions gradio/blocks.py
Expand Up @@ -884,18 +884,15 @@ def expects_oauth(self):

def unload(self, fn: Callable):
"""This listener is triggered when the user closes or refreshes the tab, ending the user session.
It is useful for cleaning up resources when the app is closed.
Parameters:
fn: Callable function to run to clear resources. The function should not take any arguments and the output is not used.
Example:
import gradio as gr
with gr.Blocks() as demo:
gr.Markdown("# When you close the tab, hello will be printed to the console")
demo.unload(lambda: print("hello"))
demo.launch(share=True, auth=("username", "password"))
demo.launch()
"""
self.set_event_trigger(
targets=[EventListenerMethod(None, "unload")],
Expand Down
1 change: 0 additions & 1 deletion gradio/components/state.py
Expand Up @@ -17,7 +17,6 @@ class State(Component):
"""
Special hidden component that stores session state across runs of the demo by the
same user. The value of the State variable is cleared when the user refreshes the page.
Demos: interface_state, blocks_simple_squares, state_cleanup
Guides: real-time-speech-recognition
"""
Expand Down

0 comments on commit 6aec8fe

Please sign in to comment.