Skip to content

Commit 426522d

Browse files
disable stage3 by default. show link to metapensiero.pj in README
Signed-off-by: Richard Barella <ribab127@gmail.com>
1 parent b7d6a35 commit 426522d

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ When building Dash applications, you often need to write clientside callback fun
1010

1111
`better-dash-callback` provides a solution to this problem by allowing you to write clientside callback functions using Python syntax. This makes your code more readable, maintainable, and efficient.
1212

13+
## Dependencies
14+
15+
`better-dash-callback` depends on `metapensiero.pj`, a Python-to-JavaScript compiler that allows you to write Python code that can be executed in a JavaScript environment.
16+
17+
## Supported Python-to-JavaScript Syntax
18+
19+
The supported Python-to-JavaScript syntax is listed in the [metapensiero.pj documentation](https://github.com/metapensiero/metapensiero.pj). This includes support for many Python features, such as functions, classes, loops, and conditional statements.
20+
1321
## Example
1422

1523
Let's consider a simple example where we want to update the text of a component based on the value of an input component.
@@ -35,7 +43,8 @@ app.clientside_callback(
3543
}
3644
""",
3745
Output("output", "children"),
38-
Input("input", "value")
46+
Input("input", "value"),
47+
3948
)
4049

4150
if __name__ == "__main__":
@@ -74,9 +83,9 @@ As you can see, the `better-dash-callback` example is more elegant and easier to
7483
The `callback` function takes the following additional arguments:
7584

7685
* `clientside`: A boolean indicating whether the callback should be executed on the client-side (default is `False`).
77-
* `enable_es6`: A boolean indicating whether to enable ES6 syntax in the generated JavaScript code (default is `True`).
78-
* `enable_stage3`: A boolean indicating whether to enable Stage 3 syntax in the generated JavaScript code (default is `True`).
79-
* `*args` and `**kwargs`: Any arguments and keyword-arguments supported by `dash.callback` are also supported by `better-dash-callback.callback`
86+
* `disable_es6`: A boolean indicating whether to disable ES6 syntax in the generated JavaScript code and revert back to ES5 support (default is `False`).
87+
* `enable_stage3`: A boolean indicating whether to enable Stage 3 syntax in the generated JavaScript code (default is `False`).
88+
* Any arguments and keyword-arguments supported by `dash.callback` are also supported by `better-dash-callback.callback`
8089

8190
## Installation
8291

better_dash_callback/src.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import dash
44
import inspect
55

6-
def callback(*args, clientside=False, enable_es6=True, enable_stage3=True, **kwargs):
6+
def callback(*args, clientside=False, disable_es6=False, enable_stage3=False, **kwargs):
77
"""
88
A decorator to register a Dash callback. If `clientside` is True, the python callback
99
will be executed clientside using https://github.com/metapensiero/metapensiero.pj
@@ -26,7 +26,7 @@ def decorator(func):
2626
if clientside:
2727
python_code = inspect.getsource(func)
2828
python_code = python_code[python_code.find("def "):]
29-
js_code = metapensiero.pj.__main__.transform_string(python_code, enable_es6=enable_es6, enable_stage3=enable_stage3)
29+
js_code = metapensiero.pj.__main__.transform_string(python_code, enable_es6=not disable_es6, enable_stage3=enable_stage3)
3030
dash.clientside_callback(js_code, *args, **kwargs)
3131
else:
3232
@dash.callback(*args, **kwargs)

0 commit comments

Comments
 (0)