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

Preserving the type of the output of callbacks #129

Open
JinraeKim opened this issue Sep 19, 2021 · 3 comments
Open

Preserving the type of the output of callbacks #129

JinraeKim opened this issue Sep 19, 2021 · 3 comments

Comments

@JinraeKim
Copy link

Hi,
I'm new to Dash.jl so the terminology may be confusing.

In my case, I'd like to send a ComponentArray (exported from ComponentArrays.jl) from a callback to another callback.

I found that after passing through a callback, ComponentArray becomes a normal array (Vector).
Is it possible to make Dash.jl compatible with ComponentArray or any other abstract array types?

Because of the powerful abstraction of ComponentArrary and other cool array types in Julia, preserving array type would be really helpful for dealing with data manipulation.

@JinraeKim
Copy link
Author

I don't know how Dash.jl works but I guess that adding a layer only to the callbacks whose output is "shown on web" will work. Probably...?

@JinraeKim JinraeKim changed the title passed through Preserving the type of the output of callbacks Sep 19, 2021
@waralex
Copy link
Collaborator

waralex commented Oct 24, 2021

@JinraeKim The fact is that the result of the callback turns into json and is sent to the front end (i.e. to JavaScript code). The frontend knows nothing about Julia types, and in general about backend types.

As an idea for the future development of Dash.jl maybe I will make it possible to type the input parameters of callbacks. But it will work the same way, just the json coming from the frontend will not be parsed into the default type (dict or vector), but into a custom type according to some user-defined rules. But you can do the same now inside the callback, typing will just be a convenient wrapper so that the conversion happens automatically.

@alexcjohnson
Copy link
Contributor

Related: plotly/dash#1784 - not merged yet, but allows keeping some type info in the front end such that when returning it to the back end in a callback that type can be reconstructed... as well as supporting alternate and possibly more efficient serializations for certain types. If you'd like to look at that implementation and comment on how to make it more useful to Julia in the future, now's the time :)

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

3 participants