-
Notifications
You must be signed in to change notification settings - Fork 161
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client-Side State Management for seamless user interactions #138
base: localstate-management
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.db | ||
*.py[cod] | ||
*.web | ||
.web | ||
__pycache__/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1590,6 +1590,8 @@ def _get_memoized_event_triggers( | |
if isinstance(rendered_chain, str): | ||
rendered_chain = rendered_chain.strip("{}") | ||
|
||
rendered_chain = rendered_chain+'}' | ||
|
||
# Hash the rendered EventChain to get a deterministic function name. | ||
chain_hash = md5(str(rendered_chain).encode("utf-8")).hexdigest() | ||
memo_name = f"{event_trigger}_{chain_hash}" | ||
Comment on lines
1590
to
1597
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The file introduces a comprehensive framework for defining and rendering components in a Next.js application, leveraging React and custom logic for state management, event handling, and dynamic rendering. The implementation of |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ Purpose: | |
{# ============================== | ||
LIBRARY IMPORTS BLOCK | ||
============================== #} | ||
import { DispatchContext } from 'utils/context' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of doing it here, we should move this to default imports which are being used by the jinja template from utils.py file (most probably) |
||
{# | ||
Purpose: | ||
- Renders all required library imports for the current page or component. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -349,7 +349,28 @@ def format_prop( | |
|
||
chain = ",".join([format_event(event) for event in prop.events]) | ||
event = f"addEvents([{chain}], {arg_def}, {json_dumps(prop.event_actions)})" | ||
prop = f"{arg_def} => {event}" | ||
|
||
if isinstance(event, str): | ||
event = event.strip("{}") | ||
|
||
parts = chain.split('.') | ||
formatted_chain = f'{parts[0]} . {parts[1]}.{parts[2]}' | ||
|
||
# Extract "_e0.target.value" | ||
value_match = re.search(r"value:([^,)}]+)", event) | ||
if value_match: | ||
value = value_match.group(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would |
||
|
||
|
||
# Extract "state.state" | ||
message_match = re.search(r"addEvents\(\[\S+?\(\"([^.]+?\.[^.]+)", event) | ||
if message_match: | ||
message = message_match.group(1) | ||
|
||
dispatcher_line = f"const dispatcher = dispatchers['{message}'];\n" \ | ||
f"dispatcher({{ message: {value} }});" | ||
|
||
prop = f"{arg_def} =>{{ {dispatcher_line}\n{event} }}" | ||
Comment on lines
351
to
+373
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementation of event handling within the
Consider refactoring the event handling logic to address these concerns, potentially by separating concerns and simplifying the implementation.
Comment on lines
+353
to
+373
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add example as comment for each part which details the input and output from the executed code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure 👍 |
||
|
||
# Handle other types. | ||
elif isinstance(prop, str): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "nextpy" | ||
version = "0.3.3" | ||
version = "0.3.5" | ||
anubrag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description = "⚡The Pure Python Framework for Web Apps, Meticulously Optimized for 🤖AI agents🤖. World's first AMS🥇" | ||
license = "Apache-2.0" | ||
authors = ["Team dotagent <[email protected]>"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change made? Isn't
rendered_chain
working correctly previously?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed an issue with the original
rendered_chain
definition in the component.py file. The initial code is as follows:However, there seems to be a processing step that alters rendered_chain by removing the opening and closing curly brackets
{}
. This modification necessitates manually appending an additional closing curly bracket}
at the end of therendered_chain
to ensure correct rendering in the index.js file. The modified code looks like this:This workaround fixes the rendering issue.