[Issue #4] Counter example #15

Merged
HugoNijhuis merged 3 commits from issue-4-counter-example into main 2026-01-09 16:28:31 +00:00
Owner

Summary

Adds a counter example that demonstrates the core signals-based reactivity model.

Changes

  • Added examples/counter/main.go showing:
    • Creating a signal with reactive.NewSignal(0)
    • Reading with count.Get()
    • Writing with count.Set(count.Get() + 1)
    • Button click handler that increments the count
    • Reactive text that updates automatically when the signal changes

Closes #4

## Summary Adds a counter example that demonstrates the core signals-based reactivity model. ## Changes - Added `examples/counter/main.go` showing: - Creating a signal with `reactive.NewSignal(0)` - Reading with `count.Get()` - Writing with `count.Set(count.Get() + 1)` - Button click handler that increments the count - Reactive text that updates automatically when the signal changes Closes #4
HugoNijhuis added 1 commit 2026-01-09 16:00:10 +00:00
Add counter example demonstrating signals
All checks were successful
CI / build (pull_request) Successful in 28s
0f924d8e8a
Basic example showing:
- Creating a signal with NewSignal
- Reading value with Get()
- Writing value with Set()
- Button click handler
- Reactive text that updates when signal changes

Closes #4

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
Owner

Code Review

Summary

Clean, minimal example demonstrating the Iris reactive signals pattern.

Feedback

The example is well-structured but missing the decrement button mentioned in the original issue #4. The issue requested:

  • Creating a signal
  • Reading with Get()
  • Writing with Set()
  • Button click handler
  • Reactive text update

A decrement button would make the example more complete and better demonstrate the reactive updates when the value changes in either direction.

Suggested change

Add a decrement button alongside the increment:

// Button that decrements the count on click
view.Child(ui.Button(func() {
    count.Set(count.Get() - 1)
}, ui.TextFromString("Decrement")))

Please add the decrement button before merging.

## Code Review ### Summary Clean, minimal example demonstrating the Iris reactive signals pattern. ### Feedback The example is well-structured but missing the **decrement button** mentioned in the original issue #4. The issue requested: - Creating a signal - Reading with Get() - Writing with Set() - Button click handler - Reactive text update A decrement button would make the example more complete and better demonstrate the reactive updates when the value changes in either direction. ### Suggested change Add a decrement button alongside the increment: ```go // Button that decrements the count on click view.Child(ui.Button(func() { count.Set(count.Get() - 1) }, ui.TextFromString("Decrement"))) ``` Please add the decrement button before merging.
HugoNijhuis added 1 commit 2026-01-09 16:18:56 +00:00
Add decrement button to counter example
All checks were successful
CI / build (pull_request) Successful in 29s
a580df7b72
Address review feedback to include a decrement button that
demonstrates reactive updates in both directions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
HugoNijhuis added 1 commit 2026-01-09 16:19:06 +00:00
Remove accidentally committed binary
All checks were successful
CI / build (pull_request) Successful in 29s
4c022b13ac
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
Owner

Code Review - Approved

Clean, minimal example demonstrating the Iris reactive signals pattern.

Highlights

  • Proper WASM build tag
  • Clear signal creation with reactive.NewSignal(0)
  • Reactive text using ui.TextFromFunction that auto-updates
  • Both increment and decrement buttons demonstrating Set/Get pattern

Previous Feedback

Decrement button has been added as requested.

LGTM - merging.

## Code Review - Approved Clean, minimal example demonstrating the Iris reactive signals pattern. ### Highlights - Proper WASM build tag - Clear signal creation with `reactive.NewSignal(0)` - Reactive text using `ui.TextFromFunction` that auto-updates - Both increment and decrement buttons demonstrating Set/Get pattern ### Previous Feedback Decrement button has been added as requested. LGTM - merging.
HugoNijhuis merged commit d3ed52e4a6 into main 2026-01-09 16:28:31 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: flowmade-one/iris#15