1111
1212[ ![ Swift] ( https://img.shields.io/badge/Swift-5.9%2B-orange.svg?style=flat )] ( https://swift.org )
1313[ ![ SPM ready] ( https://img.shields.io/badge/SPM-ready-brightgreen.svg?style=flat-square )] ( https://swift.org/package-manager/ )
14- [ ![ Coverage] ( https://img.shields.io/badge/Coverage-97.1 %25-brightgreen.svg?style=flat )] ( # )
14+ [ ![ Coverage] ( https://img.shields.io/badge/Coverage-98%2B %25-brightgreen.svg?style=flat )] ( # )
1515[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( ./LICENSE )
1616[ ![ Size] ( https://img.shields.io/badge/Package_Size-1.5MB-purple.svg?style=flat-square )] ( # )
1717
@@ -59,7 +59,7 @@ A powerful, type-safe caching library for Swift that provides multiple storage s
5959- Built on ** Swift Concurrency** (` async/await ` )
6060- ** Actor isolation** for safe persistence without manual locks
6161- Generic, type-safe APIs
62- - ** Combine** publishers for reactive data flow
62+ - ** Combine** publishers for reactive data flow with simplified API
6363
6464⚡ ** Performance**
6565- LRU eviction in memory & disk
@@ -283,8 +283,8 @@ cache.publisher(for: "current_user")
283283 }
284284 .store (in : & cancellables)
285285
286- // Observe only future changes (skip current value)
287- cache.publisher (for : " current_user" , emitInitial : false )
286+ // Observe changes (current value is always emitted )
287+ cache.publisher (for : " current_user" )
288288 .compactMap { $0 }
289289 .sink { user in
290290 print (" User changed: \( user.name ) " )
@@ -301,31 +301,41 @@ cache.publisher(for: "user_id")
301301 // Handle user details
302302 }
303303 .store (in : & cancellables)
304+
305+ // Skip initial value if you only want future updates
306+ cache.publisher (for : " current_user" )
307+ .dropFirst () // Skip the immediate current value emission
308+ .compactMap { $0 }
309+ .sink { user in
310+ print (" User changed: \( user.name ) " )
311+ }
312+ .store (in : & cancellables)
304313```
305314
306- #### Publisher Options
315+ #### Publisher Behavior
307316
308- All Pandora publishers support an ` emitInitial ` parameter to control whether the current value is emitted immediately upon subscription:
317+ All Pandora publishers emit the current value immediately upon subscription, followed by any future changes :
309318
310- - ` publisher(for: "key") ` - Emits current value immediately (default behavior)
311- - ` publisher(for: "key", emitInitial: true) ` - Explicitly emit current value
312- - ` publisher(for: "key", emitInitial: false) ` - Only emit future changes
319+ - ` publisher(for: "key") ` - Emits current value immediately, then future changes
320+ - Use ` .dropFirst() ` if you only want to observe future changes, not the current value
313321
314322### Cache Cleanup
315323
316324``` swift
317- // Clear specific cache
318- cache.clear ()
319- await diskCache.clear ()
320-
321- // Remove all Pandora disk caches for this app
322- Pandora.clearAllDiskData ()
323-
324- // Remove all keys from this app's UserDefaults and iCloud KVS
325- Pandora.clearUserDefaults ()
326-
327- // Remove everything above (nuclear option)
328- Pandora.deleteAllLocalStorage ()
325+ // Clear specific cache instances
326+ memoryCache.clear () // Synchronous for MemoryBox
327+ await diskCache.clear () // Asynchronous for DiskBox
328+ await hybridCache.clear () // Asynchronous for HybridBox
329+ await userDefaultsCache.clear () // Asynchronous for UserDefaultsBox
330+
331+ // Clear specific namespaces
332+ Pandora.clearUserDefaults (for : " my_settings" ) // Clear specific UserDefaults namespace
333+ Pandora.clearDiskData (for : " my_cache" ) // Clear specific disk namespace
334+
335+ // Clear all data
336+ Pandora.clearAllUserDefaults () // Clear all Pandora UserDefaults data
337+ Pandora.clearAllDiskData () // Clear all Pandora disk caches
338+ Pandora.deleteAllLocalStorage () // Nuclear option - clear everything
329339```
330340
331341## Thread Safety
0 commit comments