Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for reactive expressions #26

Closed
anandology opened this issue Jun 22, 2017 · 3 comments
Closed

Add support for reactive expressions #26

anandology opened this issue Jun 22, 2017 · 3 comments

Comments

@anandology
Copy link

The current interface to specify a reactive function using decorator taking output and inputs as arguments is too verbose and doesn't feel very elegant.

Wouldn't it be better to say:

app['amount'].children = compute_amount(app['hours'].value, app['rate'].value)

instead of:

@app.callback(Output('amount', 'children'),
              [Input('hours', 'value'), Input('rate', 'value')])
def compute_amount(hours, rate):
    ...

The former one feels more natural way to specify the logic. Also, it makes it easy to use the same function in different scenarios. For example:

app['output1'].children = uppercase(app['input1'].value)
app['output2'].children = uppercase(app['input2'].value)

This would be too cumbersome to do with the current approach.

I've implemented a quick proof-of-concept code to demonstrate that such a thing is possible. The code and notes are available at:

https://gist.github.com/anandology/b93fd555215203977301ecb4994efe66

@chriddyp
Copy link
Member

Wow, this is really cool. Thanks for sharing this!

I'm going to keep this issue open to let the idea ferment a little bit longer and to promote discoverability. The verbosity of the current method with decorators isn't enough for me to warrant a new syntax, but I can imagine future versions of this package ending up using something along these lines.

The current method also allows for other types of dependency objects like Event and State, which act in a different way than Input. There is a simple example here: https://gist.github.com/chriddyp/e546a2a2c05df29c868e4cef57fb2105.

@chriddyp
Copy link
Member

chriddyp commented Jun 8, 2018

This type of syntax is similar to what is being proposed for client-side operations in #266

HammadTheOne pushed a commit to HammadTheOne/dash that referenced this issue May 28, 2021
HammadTheOne pushed a commit that referenced this issue Jul 23, 2021
@gvwilson
Copy link
Contributor

gvwilson commented Jun 3, 2024

Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson

@gvwilson gvwilson closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants