GoodRequest / GoodPersistence

💾 GoodPersistence is an iOS library that simplifies caching data in keychain and UserDefaults. Using a property wrapper, it reduces the complexity of implementing caching mechanisms, making it easier for developers to focus on app functionality. Compatible with latest Swift and supports all iOS devices. Easy to install with SPM.
MIT License
35 stars 1 forks source link

Using valuePublisher completes on first error #7

Closed DominikPetho closed 3 months ago

DominikPetho commented 7 months ago

Describe the bug In case we are subscribed to valuePublisher, after first error passed to subject, subject completes and is not reinitialized. After error we are unable to receive new values passed to keychain.

To Reproduce Steps to reproduce the behavior:

  1. Create Keychain
  2. Subscribe to valuePublisher
  3. Try to force error inside keychain property
  4. Pass valid value to property
  5. New value is not receiver in valuePublisher

Expected behavior After receiving error, I am able to receive next values.

Additional context Suggested solution:

  1. private let newSubject: PassthroughSubject<Either<T, KeychainError>, Never> = PassthroughSubject()
  2. private let newSubject: PassthroughSubject<Event<T, KeychainError>, Never> = PassthroughSubject()
andrej-jasso commented 3 months ago

We removed error emitting and allowed just value emitting. Also methods to retrieve and save data throw errors which are logged and you can connect on the logger now