diff --git a/README.md b/README.md index e2c7bd9..e71d919 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ Embed an Observable notebook into the Streamlit app. If any cells are passed int - `observe`: An optional list of cell names to observe. When those cells are updated in the Observable notebook, the new values will be sent back to Streamlit as part of the return value. Keep in mind, there is a serialization process from going from Observable notebook JavaScript -> Streamlit Python (JSON serializing). - `redefine`: An optional dict of cell names and values used to redefine in the embeded notebook. Keep in mind, there is a serialization process from going from Streamlit Python -> Observable notebook JavaScript (JSON serializing). - `hide`: An optional list of cell names that will not be rendered in the DOM of the embed. Useful for side-effect logic cells, like `mouse` in https://observablehq.com/@mbostock/eyes. +- `debounce`: An optional delay in milliseconds. Observed values don't change until a delay after the last update is less than the option value. ## Caveats @@ -138,4 +139,4 @@ I haven't tried this, but I expect that if you try loading 1GB+ of data into a b ### You'll need to fork a lot -Most Observable notebooks are built with only other Observable users in mind. Meaning, a lot of cells are exposed as custom Objects, Dates, functions, or classes, all of which you can't control very well in Python land. So, you may need to fork the notebook you want in Observable, make changes to make it a little friendlier, then publish/enable link-sharing to access in Streamlit. Thankfully, this is pretty quick to do on Observable once you get the hang of it, but it does take extra time. \ No newline at end of file +Most Observable notebooks are built with only other Observable users in mind. Meaning, a lot of cells are exposed as custom Objects, Dates, functions, or classes, all of which you can't control very well in Python land. So, you may need to fork the notebook you want in Observable, make changes to make it a little friendlier, then publish/enable link-sharing to access in Streamlit. Thankfully, this is pretty quick to do on Observable once you get the hang of it, but it does take extra time. diff --git a/setup.py b/setup.py index bbff5a7..6ec25ba 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def get_long_description(): setuptools.setup( name="streamlit-observable", - version="0.0.8", + version="0.1.0", author="Alex Garcia", author_email="alexsebastian.garcia@gmail.com", description="A Streamlit component for embedding Observable notebooks in Streamlit Apps", diff --git a/streamlit_observable/__init__.py b/streamlit_observable/__init__.py index b012050..2874ec7 100644 --- a/streamlit_observable/__init__.py +++ b/streamlit_observable/__init__.py @@ -14,7 +14,7 @@ _component_func = components.declare_component("observable", path=build_dir) -def observable(key, notebook, targets=None, redefine={}, observe=[], hide=[]): +def observable(key, notebook, targets=None, redefine={}, observe=[], hide=[], debounce=None): """Create a new instance of "observable". Parameters @@ -37,8 +37,12 @@ def observable(key, notebook, targets=None, redefine={}, observe=[], hide=[]): redefine, the values are what they will be redefined as. Keep in mind, there is a serialization process from Streamlit Python -> frontend JavaScript. hide: list or None - An option list of strings that are the names of cells that will be embeded, + An optional list of strings that are the names of cells that will be embeded, but won't be rendered to the DOM. + debounce: float or None + An optional delay in milliseconds. + Observed values don't change + until a delay after the last update is less than the option value. Returns ------- dict @@ -54,7 +58,8 @@ def observable(key, notebook, targets=None, redefine={}, observe=[], hide=[]): redefine=redefine, hide=hide, key=key, - name=key + name=key, + debounce=debounce ) if component_value is None: diff --git a/streamlit_observable/frontend/package.json b/streamlit_observable/frontend/package.json index fb628e6..c24ba3c 100644 --- a/streamlit_observable/frontend/package.json +++ b/streamlit_observable/frontend/package.json @@ -4,23 +4,16 @@ "private": true, "dependencies": { "@observablehq/runtime": "^4.7.2", - "@testing-library/jest-dom": "^4.2.4", - "@testing-library/react": "^9.3.2", - "@testing-library/user-event": "^7.1.2", - "@types/hoist-non-react-statics": "^3.3.1", - "@types/jest": "^24.0.0", - "@types/node": "^12.0.0", - "@types/react": "^16.9.0", - "@types/react-dom": "^16.9.0", - "apache-arrow": "^0.17.0", - "bootstrap": "^4.4.1", - "event-target-shim": "^5.0.1", - "hoist-non-react-statics": "^3.3.2", "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "3.4.1", + "streamlit-component-lib": "^1.4.0", "typescript": "~3.7.2" }, + "devDependencies": { + "@types/react": "^16.9.0", + "@types/react-dom": "^16.9.0" + }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", diff --git a/streamlit_observable/frontend/public/index.html b/streamlit_observable/frontend/public/index.html index f0abf81..a458376 100644 --- a/streamlit_observable/frontend/public/index.html +++ b/streamlit_observable/frontend/public/index.html @@ -11,7 +11,7 @@ href="https://cdn.jsdelivr.net/npm/@observablehq/inspector@3/dist/inspector.css" /> -
+ - \ No newline at end of file +