Swiftpack.co - Package - ragzy15/PublisherKit

Publisher Kit

Platforms Languages Swift Package Manager compatible Carthage compatible CocoaPods Compatible

Overview

PublisherKit provides a declarative Swift API for processing asynchronous events over time. It is an open source version of Apple’s Combine Framework with many other additions.

The goal of this project is to provide a compatible, reliable and efficient implementation of Combine Framework that can be used on Apple’s operating systems older than macOS 10.15, iOS 13, tvOS 13 and watchOS 6.

To know more about Combine Framework, refer to Apple's Documentation here.

Supported Platforms

  • Xcode 11 and above

Deployment Targets

  • iOS 8 and above
  • macOS (OS X) 10.10 and above
  • tvOS 9 and above
  • watchOS 3 and above

Installation

Swift Package Manager

To integrate PublisherKit into your project using Swift Package Manager, you can add the library as a dependency in Xcode (11 and above) – see the docs. The package repository URL is:

https://github.com/ragzy15/PublisherKit.git

Alternatively, you can add PublisherKit as a dependency in your Package.swift file. For example:

// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "YourPackage",
    products: [
        .library(
            name: "YourPackage",
            targets: ["YourPackage"]),
    ],
    dependencies: [
        .package(url: "https://github.com/ragzy15/PublisherKit.git", from: "4.0.2"),
    ],
    targets: [
        .target(
            name: "YourPackage",
            dependencies: ["PublisherKit"]),
    ]
)

You can install by using swift package manager built into Xcode or clone the repository and add a sub project into your project.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

If you don't already have the Cocoapods gem installed, run the following command:

$ gem install cocoapods

To integrate PublisherKit into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

pod 'PublisherKit', '~> 4.0.2'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate PublisherKit into your Xcode project using Carthage, specify it in your Cartfile:

github "ragzy15/PublisherKit"

Usage

searchTextField.textDidChangePublisher
    .debounce(for: .milliseconds(300), scheduler: DispatchQueue.main)
    .compactMap { (text) -> String? in
        text.isEmpty ? nil : text
    }
    .removeDuplicates()
    .flatMap { (text) -> AnyPublisher<SearchResults, Never> in
        self.search(with: text)
    }
    .receive(on: DispatchQueue.main)
    .sink { (results) in
        print(results)
    }
    .store(in: &cancellables)

There is also a demo project included.

Communication

  • Please open an issue if you find a bug or have a feature request.
  • Please submit a pull request if you would like to contribute (some tests would be nice).

Thanks ;)

Github

link
Stars: 4

Dependencies

Used By

Total: 0

Releases

Release 4.0.2 - 2020-04-19 18:11:53

HTTPURLResponse in DataTaskPKPublisher, DownloadTaskPKPublisher, UploadTaskPKPublisher has updated to URLResponse. Validate Publisher currently works only for HTTP URL Requests.

Release 4.0.1 - 2020-04-18 20:28:21

Fixed FirstMatch and Matches publisher

Release 4.0.0 - 2020-04-18 18:25:18

Removed Deprecations Added All Combine Publishers except ObservableObject Added AssignNoRetain publisher which fixes a flaw in Assign publisher that object is stored with a strong reference, which may cause memory leak Added Carthage and Cocoapods support

Release 3.0.0 - 2020-02-18 20:12:42

Updated Publishers with Locks. Removed the prefix ‘PK’ wherever possible, to match Combine. Added new publishers: DownloadTaskPublisher, UploadTaskPublisher, RemoveDuplicates, Breakpoint, Contains, Print, Reduce, SetFailureType. Restructured internal subscribers. Bug Fixes.