Package that extends Combine with some useful APIs

Overview

CombineExpanded

Package that extends Combine with some useful APIs.

New API:

  • then
  • shareReplay
  • Future.deferred

then

Wait for completion of self, then forward all events from next. All values sent from self are ignored.

.deferred { future in future(.success(2)) }.handleEvents(receiveCompletion: { _ in print("completed 2") }) publisher1.then(publisher2) .sink { print($0) } // output: // completed 1 // 2 // completed 2 ">
let publisher1 = Future<Int, Never>.deferred { future in
    future(.success(1))
}.handleEvents(receiveCompletion: { _ in
    print("completed 1")
})

let publisher2 = Future<Int, Never>.deferred { future in
    future(.success(2))
}.handleEvents(receiveCompletion: { _ in
    print("completed 2")
})

publisher1.then(publisher2)
    .sink {
        print($0)
    }

// output: 
// completed 1
// 2
// completed 2

shareReplay

Creates a new Publisher that will multicast values emitted by the underlying publisher, up to bufferSize. All clients of this Publiher will see the same version of the emitted values/errors.

The underlying Publisher will not be started until self is started for the first time. When subscribing to this producer, all previous values (up to bufferSize) will be emitted, followed by any new values.

let publisher = Future<Void, Never>.deferred { future in
    print("started")
    future(.success(()))
}.shareReplay(1)

publisher
    .sink(receiveCompletion: { _ in },
          receiveValue: {})
    .store(in: &cancellables)

publisher
    .sink(receiveCompletion: { _ in },
          receiveValue: {})
    .store(in: &cancellables)

// output:
// started

Future.deferred

Delays Future start until it is subscribed.

let future = Future<Void, Error>.deferred { future in
    print("started")
    future(.success(()))
}
print("before")
future.sink(receiveCompletion: { _ in },
            receiveValue: { _ in })
    .store(in: &cancellable)
print("after")

// output:
// before
// started
// after
You might also like...
Open-source implementation of Apple's Combine for processing values over time

CombineX 简体中文 Open-source implementation of Apple's Combine for processing values over time. Though CombineX have implemented all the Combine interfac

A macOS application for accessing the output of the SimpleAnalytics package on the desktop.
A macOS application for accessing the output of the SimpleAnalytics package on the desktop.

The SimpleAnalytics package allows you to collect data user interaction analytic data in iOS and macOS applications. This SimpleAnalytics Reader app project allows you to more easily make sense of that collected data by displaying it on your Mac.

Flutter package for detecting NSFW images and videos using native implementation

Flutter NSFW 1- Download, tflite modle and put it in assets folder 2 - Add the path of the tfliet to pubspec.yaml 3 - Read the file using path_provide

React Native package for interacting with HomeKit devices

React Native package for interacting with HomeKit devices

This repository hosts the PushwooshGeozones iOS SDK as an XCFramework based Swift Package.

This repository hosts the PushwooshGeozones iOS SDK as an XCFramework based Swift Package. Use this repository's Swift Package in Xcode 12+

A corresponding package to RxKotlin Plus, but for Swift and iOS

A corresponding package to RxKotlin Plus, but for Swift and iOS

A simple protocol package that does nothing

HasResult A simple protocol package that does nothing. The HasResult protocol has a simple result property and a ResultType associated type. This is m

A Swift package for encoding and decoding Swift Symbol Graph files.
A Swift package for encoding and decoding Swift Symbol Graph files.

SymbolKit The specification and reference model for the Symbol Graph File Format. A Symbol Graph models a module, also known in various programming la

FlutterNativeDragAndDrop - A package that allows you to add native drag and drop support into your flutter app
FlutterNativeDragAndDrop - A package that allows you to add native drag and drop support into your flutter app

native_drag_n_drop A package that allows you to add native drag and drop support

Owner
Cogniteq
Cogniteq
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

null 8.3k Dec 31, 2022
The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.

QuoteKit The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey. It uses the latest async/await syntax for

rryam 17 Jun 23, 2022
A zero-code template app that demonstrates how to use TheraForge's APIs and can be used for fast prototyping

TheraForge MagicBox 1.0.0-beta The Open TheraForge (OTF) MagicBox app is a template for creating digital health solutions that help people better mana

TheraForge 0 Dec 23, 2021
You can monitor your APIs and websites on your menubar. Gives you status code 🎉 Cool & good

Hope not. Monitor your APIs and websites on your menubar. For macOS. Right now! YyeeeHav!

Steven J. Selcuk 10 Nov 29, 2022
Some code for playing with the Teenage Engineering Ortho Remote

ortho-remote C program for interfacing with the Teenage Engineering Ortho Remote. Currently only implemented for macOS Puts the remote into MIDI mode

Rasmus 13 Oct 18, 2022
Some helpful swift code snippets

HelpfulSwiftSnippets Some helpful swift code snippets Network Manager - a generic network manager that deals with downloading data from the internet u

null 2 Oct 17, 2021
A Swift Recreation of Attach-Detach, with some configurable options

Attach-Detach-Sw A Swift Recreation of Attach-Detach, with some configurable options Usage To use, you'll need to specify if you are attaching or deta

Dabezt 1 Dec 24, 2021
Mybook swiftui - A Facebook UI Clone with some capabilities like like/unlike, comment, scroll, show stories etc

mybook_swiftui ?? Trying to create a Facebook UI Clone with some capabilities li

mogolAyberk 1 Apr 16, 2022
Provides some Apple Wallet functionality, like adding passes, removing passes and checking passises for existing.

react-native-wallet-manager Provides some Apple Wallet's functionality, like adding passes, removing passes and checking passises for existing. Instal

dev.family 50 Nov 12, 2022
A Swift Playground to play around Combine

CombinePlayground A Swift Playground to play around Combine Why made this playground To help myself learn Combine, I re-implemented the same features

Jake Lin 5 Apr 17, 2022