Releases: gokulnair2001/Pledge
v1.0.0
Pledge Framework Release Notes
Version 1.0.0
We're excited to announce the release of Pledge, a lightweight reactive programming framework for Swift applications!
Key Features
-
Thread-Safe Observables: The core
PLObservable<T>class provides a thread-safe container that notifies subscribers when values change. -
Global Event Bus:
PLGlobalStoreacts as a lightweight event bus for app-wide state management, with type-specific convenience methods. -
Priority-Based Notifications: Subscribers can be assigned different priority levels to control the order of notifications.
-
Queue-Specific Delivery: Easily specify which dispatch queue (including the main queue) notifications should be delivered on.
-
Flexible Rate Limiting:
- Throttling: Limit the frequency of notifications to prevent excessive updates
- Debouncing: Only process the most recent update after a quiet period
-
Batch Updates: Group multiple value changes to trigger only a single notification when complete.
-
Rich Operator Support:
- Transformations:
map,flatMap,compactMap - Filtering:
filter,skip,distinctUntilChanged - Combining:
merge,zip - Result Type Extensions: Special operators for working with Result types
- Transformations:
Implementation Details
- Memory-safe implementation with automatic cleanup of resources
- Concurrent queue with barrier flags for thread-safe read/write operations
- Customizable subscription options
Usage Example
// Create an observable with an initial value
let nameObservable = PLObservable<String>("John")
// Subscribe to changes, delivering on the main queue
nameObservable.deliverOnMain().subscribe { newName in
print("Name changed to: \(newName)")
}
// Subscribe with debounce to avoid processing rapid changes
nameObservable.debounce(for: 0.5).subscribe { name in
print("Processing name after debounce: \(name)")
}
// Update the value, triggering notifications to subscribers
nameObservable.setValue("Jane")
// Use the global store for app-wide state
let counter = PLGlobalStore.shared.integer(for: "counter")
counter.subscribe { value in
print("Counter changed: \(value)")
}Requirements
- Swift 5.0+
- iOS 12.0+, macOS 10.14+, tvOS 12.0+, watchOS 5.0+
Coming Soon
- Additional operators for more complex transformations
- Comprehensive documentation and examples
We welcome your feedback and contributions! Please report any issues on our GitHub repository.