-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9973403
commit 101f768
Showing
10 changed files
with
118 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from reactpy import component, html | ||
from reactpy_django.hooks import use_mutation | ||
from reactpy_django.types import MutationOptions | ||
|
||
|
||
def execute_thread_safe_mutation(): | ||
"""This is an example mutation function that does some thread-safe operation.""" | ||
pass | ||
|
||
|
||
@component | ||
def my_component(): | ||
item_mutation = use_mutation( | ||
MutationOptions(thread_sensitive=False), | ||
execute_thread_safe_mutation, | ||
) | ||
|
||
def submit_event(event): | ||
if event["key"] == "Enter": | ||
item_mutation.execute(text=event["target"]["value"]) | ||
|
||
if item_mutation.loading or item_mutation.error: | ||
mutation_status = html.h2("Doing something...") | ||
elif item_mutation.error: | ||
mutation_status = html.h2("Error!") | ||
else: | ||
mutation_status = html.h2("Done.") | ||
|
||
return html.div( | ||
html.input({"type": "text", "onKeyDown": submit_event}), | ||
mutation_status, | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.