Open T4rk1n opened 5 years ago
Great yes this could be a way to add direct Dataframe parsing support to plotly/dash-table
I refactored the component generation, now every prop will have a descriptor that fires a prop change event (for the backend code only). The returned value from the handler will be the actual value used by the component.
Example dataframe serialization:
def on_prop_change(component, prop_name, old_value, new_value, prop_type):
if isinstance(new_value, pd.DataFrame):
return new_value.to_dict('records')
return new_value
Two options for the prop changes events:
Generate the _component_class._ComponentClass
and component_class.Component
so the user can override methods & attributes
PROS:
CONS:
Add handlers to global object (ComponentRegistry)
PROS:
CONS:
I favor the second option.
The generated components gets overwritten every time we run the generation. We can't add python code to them because of that. It would be useful if we could add code that could modify the props before sending it to the front-end.
Solution proposal:
_ComponentClass.py
file that gets overwritten.ComponentClass.py
only if it doesn't exist, it import_ComponentClass
and subclass it.