Skip to content

Add reaktiv order calculator example - #5783

Merged
falkoschindler merged 7 commits into
zauberzeug:mainfrom
evnchn:add-reaktiv-example
Feb 16, 2026
Merged

Add reaktiv order calculator example#5783
falkoschindler merged 7 commits into
zauberzeug:mainfrom
evnchn:add-reaktiv-example

Conversation

@evnchn

@evnchn evnchn commented Feb 14, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Addresses #4758 (comment)

Adds a new example demonstrating integration with the reaktiv reactive state management library. This showcases an alternative approach to state management in NiceGUI using fine-grained reactive signals.

Implementation

The example is an order calculator with:

  • Signals for user inputs (price, quantity, tax rate)
  • Computed values for derived state (subtotal, tax, total) forming a diamond dependency graph
  • Effects to automatically update NiceGUI labels when any dependency changes

Requires reaktiv >= 0.21.1 which fixes a diamond dependency graph bug (buiapp/reaktiv#27).

Progress

  • I chose a meaningful title that completes the sentence: "If applied, this PR will..."
  • The implementation is complete.
  • If this PR addresses a security issue, it has been coordinated via the security advisory process.
  • Pytests have been added (or are not necessary).
  • Documentation has been added (or is not necessary).

Demonstrates reactive state management with the reaktiv library,
using Signal, Computed, and Effect primitives to drive NiceGUI UI updates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@evnchn evnchn added the documentation Type/scope: Documentation, examples and website label Feb 14, 2026
@falkoschindler falkoschindler added the review Status: PR is open and needs review label Feb 16, 2026
@falkoschindler
falkoschindler self-requested a review February 16, 2026 15:57
Comment thread examples/reaktiv/main.py Outdated
@falkoschindler falkoschindler added this to the 3.8 milestone Feb 16, 2026
@evnchn

evnchn commented Feb 16, 2026

Copy link
Copy Markdown
Collaborator Author

Hmm. Should add some comments to group the related bindings.

And we should give some more thought to binding.combine in another PR.

Perhaps a strict=True to disable the polling fallback for non-type-annotation dataclass attributes.

@falkoschindler falkoschindler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think this is good enough for now.
Let's merge 👍🏻

@falkoschindler
falkoschindler added this pull request to the merge queue Feb 16, 2026
Merged via the queue into zauberzeug:main with commit be4d520 Feb 16, 2026
7 checks passed
buiapp added a commit to buiapp/nicegui that referenced this pull request Feb 19, 2026
…collection

Effects in reaktiv must be assigned to variables, otherwise they get
garbage collected and stop working. The previous example only worked due to a bug in reaktiv that has since been fixed. Updated the example to properly store Effect instances.

zauberzeug#5783, zauberzeug#4758
github-merge-queue Bot pushed a commit that referenced this pull request Feb 19, 2026
…collection (#5812)

### Motivation

Effects in reaktiv must be assigned to variables, otherwise they get
garbage collected and stop working. The previous example only worked due
to a bug in reaktiv that has since been fixed. Updated the example to
properly store Effect instances.

This API behavior is documented in the reaktiv docs.

References: #5783, #4758

### Implementation

We need just to assign Effects to variables.

### Progress

- [x] I chose a meaningful title that completes the sentence: "If
applied, this PR will..."
- [x] The implementation is complete.
- [x] If this PR addresses a security issue, it has been coordinated via
the [security
advisory](https://github.com/zauberzeug/nicegui/security/advisories/new)
process.
- [x] Pytests have been added (or are not necessary).
- [x] Documentation has been added (or is not necessary).
@evnchn
evnchn deleted the add-reaktiv-example branch March 29, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Type/scope: Documentation, examples and website review Status: PR is open and needs review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants