Skip to content

Conversation

@victor-sarda
Copy link

Problem

After calling removeOverrides() or delete() from ToggleManager, impacted ToggleObservable elements would stop responding to subsequent value changes. Subscribers would receive completion events and become permanently inactive.

Root Cause

The removeOverrides() and delete() methods were completing and removing all CurrentValueSubject publishers from the internal subjectsRefs dictionary. This caused:

  • All active subscribers to receive completion events and unsubscribe
  • Publishers to become permanently inactive, preventing any future value updates
  • Loss of reactivity for all previously subscribed views

Fix

I updated ToggleManager.swift and ToggleManager+Overrides.swift to preserve publisher lifecycle:

Instead of completing and removing publishers, the methods now send new values (reverting to defaults) to existing subjects. Publishers remain active in subjectsRefs and continue functioning after override removal.

Subscribers remain subscribed and properly receive the new default values through the publisher.

Note

I also refactored the demo app Observables tab to add interactive UI elements to test ToggleObservables easily.

Attachments

  • The "Before" video shows how the boolean value stopped reacting to changes after resetting the overrides.
  • The "After" video shows how it keeps reacting after resetting. It also shows that interacting with the UI switch correctly updates the ToggleDetailView, even after resetting overrides.
Before After
Simulator Screen Recording - iPhone 17 Pro - 2025-12-05 at 14 09 40 Simulator Screen Recording - iPhone 17 Pro - 2025-12-05 at 14 11 46

Copy link
Member

@albertodebortoli albertodebortoli left a comment

Choose a reason for hiding this comment

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

Thanks a bunch. These changes are very much appreciated :)

@albertodebortoli albertodebortoli merged commit 156595a into TogglesPlatform:main Dec 5, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants