widgetti / ipyreact

React for ipywidgets that just works. No webpack, no npm, no hassle
BSD 3-Clause "New" or "Revised" License
104 stars 8 forks source link

added an example showing bidirectional binding between python/react for complex objects #9

Open paddymul opened 1 year ago

paddymul commented 1 year ago

bi-directional binding between jupyter and python works... as long as you replace the entire object from both sides. As is react best practice.

kolibril13 commented 1 year ago

and one more observation: when I change the parameter bar in the second example

z = UpdateDictFromReactWidget()
z.simple_dict["bar"] = 3000

bar does not update to 3000 as well when I press the increment bar button. bar only gets the new value after pressing the times confetti button. As before, z.simple_dict = {'foo':2, 'bar':2, 'baz':2} updates everything immediately.

maartenbreddels commented 1 year ago

Note that trailets doesn’t detect mutations of objects, only assignment. This reflect the Python language. Not something we can change I think.

On Fri, 28 Apr 2023 at 12:01, Jan-Hendrik Müller @.***> wrote:

and one more observation: when I change the parameter bar in the second example

z = UpdateDictFromReactWidget() z.simple_dict["bar"] = 3000

bar does not update to 3000 as well when I press the increment bar button. bar only gets the new value after pressing the times confetti button. As before, z.simple_dict = {'foo':2, 'bar':2, 'baz':2} updates everything immediately.

— Reply to this email directly, view it on GitHub https://github.com/widgetti/ipyreact/pull/9#issuecomment-1527308193, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANPEPL5QM443K3SS2XLYODXDOIONANCNFSM6AAAAAAXLGOXBM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Maarten Breddels Co-Founder of Widgetti https://widgetti.io/ Your partner for Jupyter- and data-apps Tel: +31 6 2464 0838 <+31+6+24640838> [image: Twitter] https://twitter.com/maartenbreddels[image: Github] https://github.com/maartenbreddels[image: LinkedIn] https://linkedin.com/in/maartenbreddels

kolibril13 commented 1 year ago

Thanks a lot for your time and for this review! Really looking forward to reading and incorporating your comments later today!