reactive-python / reactpy-django

It's React, but in Python. Now with Django integration.
https://reactive-python.github.io/reactpy-django/
MIT License
322 stars 18 forks source link

Async ORM mutations and queries #134

Closed Archmonger closed 1 year ago

Archmonger commented 1 year ago

Description

fix https://github.com/reactive-python/reactpy-django/issues/135

Checklist:

Please update this checklist as you complete each item:

Archmonger commented 1 year ago

@rmorshea I'm seeing some weird behavior that might indicate a bug with async use_effect hooks.

Let me know when you have time for me to demo.

rmorshea commented 1 year ago

I'll have time in an hour.

Archmonger commented 1 year ago

Ops forgot to add async mutation support...

EDIT: Past me apparently already semi-developed it, but I'm not sure what direction to take for a thread_sensitive parameter for mutations. I think we might need to create a MutationOptions data type.

Archmonger commented 1 year ago

@rmorshea

Regarding a thread_sensitive parameter for mutations, which approach do we want to take?

  1. Create a MutationOptions data type with a thread_senstive parameter.
  2. Assume all sync mutations are thread_sensitive
    • If we do this, we should probably make the same assumption for our use_query hook
  3. Add a thread_sensitive=... kwarg directly to use_mutation
    • This might feel weird, since it ends up being a different API than use_query
Archmonger commented 1 year ago

I opted for use_mutation with MutationOptions since I think it's the only API that doesn't feel mismatched when comparing to use_query with QueryOptions.

We should re-evaluate when merging these hooks into core.

In the future, I'd like these settings to either be kwargs or a TypeDict (assuming editors start having TypeDict auto completion)

Archmonger commented 1 year ago

This PR is ready for review.

I did a tabletop self-review and cleaned up a couple things.

rmorshea commented 1 year ago

Will try to find time. Going to be quite busy the next two weeks.

Archmonger commented 1 year ago

I played around with the test to get things running faster and more reliably.

Archmonger commented 1 year ago

@rmorshea Can we schedule a review for this one?