Swiftpack.co - banjun/ReactiveSSE as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by banjun.
banjun/ReactiveSSE 0.4.0
Server Sent Events (SSE) parser operators for ReactiveSwift
⭐️ 3
🕓 1 year ago
linux macOS iOS
.package(url: "https://github.com/banjun/ReactiveSSE.git", from: "0.4.0")

ReactiveSSE

CI Version License Platform

ReactiveSSE is a ReactiveSwift.SignalProducer acting as Server-Sent Events (SSE) parser. https://www.w3.org/TR/eventsource/

SSE stream is buffered and parsed in a background queue and can be observed via its signal.

Usage

let sse = ReactiveSSE(urlRequest: URLRequest(url: URL(string: endpoint)!))
sse.producer.observe(on: QueueScheduler.main).startWithValues { (v: SSEvent) in
    v.type // String: "message", "update", or whatever
    v.data // String: json payload string, any value string, or whatever
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

ReactiveSSE is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ReactiveSSE'

Author

@banjun

License

ReactiveSSE is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 3
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics