Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork23
UserModel
related hooks, decorators, and settings#190
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
UserModel
related hooks and decoratorsUserModel
related hooks, decorators, and settingsArchmonger commentedDec 13, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@rmorshea I need your opinion on the
fromreactpyimportcomponent,htmlfromreactpy_django.hooksimportuse_user_data@componentdefmy_component():# user_data properties: current, loading, error# user_data callable attributes: refetch# set_user_data properties: loading, error# set_user_data callable attributes: __call__, resetuser_data,set_user_data=use_user_data()# Here's an example that uses most of the APIasyncdefon_key_press(event):ifevent["key"]=="Enter":# User data is always a dictmerged_data=user_data.current| {uuid4():event["target"]["value"]}set_user_data(merged_data)returnhtml.div(html.input({"placeholder":"Type some user data here...","on_key_press":on_key_press}),html.div(f"Data:{user_data.current}"),html.div(f"Data Loading:{user_data.loading}"),html.div(f"Set Data Loading:{set_user_data.loading}"),html.div(f"Error(s):{user_data.error}{set_user_data.error}"), ) To get the conversation started, here's a few questions/concerns I have:
|
rmorshea commentedDec 17, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'll try and take a look in the next couple days. |
Would you have time to look at the interface proposed in theabove comment this weekend? This PR is fairly bulky and has a lot of Django-only jargon, so a PR review won't be needed. |
Sure. I'll make time today or tomorrow. |
rmorshea commentedDec 31, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
My take is that the marginal UX improvements made by creating special wrappers for the query and mutation objects may be outweighed by requiring the user to learn something new. It seems easier to explain to the user that To address some of the usability concerns in a slightly simpler way, we could consider adding a user_data=use_user_data()# access datauser_data.query.datadefsome_callback():new_user_data=user_data.query.data| {...}user_data.mutation(new_user_data) |
Agreed, will implement soon. |
Uh oh!
There was an error while loading.Please reload this page.
Description
User
related features!reactpy_django.hooks.use_user
can be used to access the current user.reactpy_django.hooks.use_user_data
provides a simplified interface for storing user key-value data.reactpy_django.decorators.user_passes_test
is inspired by Django'suser_passes_test
decorator, but works with ReactPy components.settings.py:REACTPY_AUTO_RELOGIN
will cause component WebSocket connections to automaticallyre-login users that are already authenticated. This is useful to continuously updatelast_login
timestamps and refresh theDjango login session.Checklist:
Please update this checklist as you complete each item:
By submitting this pull request you agree that all contributions comply with this project's open source license(s).