SampledPublisher - The SampledPublisher samples the output of a publisher based on events from another publisher

Overview

SampledPublisher

The SampledPublisher samples the output of a publisher based on events from another publisher.

Usage

This example shows how to sample the value from a "temperature publisher" every 60 seconds. The temperature sensor may send many values while the timer sends one value exectly every 60 seconds. By sampling the timer, the resulting Publisher emits the most recent temperature measurement every 60 seconds.

Note that a value is not sampled twice.

If the temperature sensor does not emit a value during for a complete minute, no value is send by the sampled publisher.

    let timer = Timer.publish(every: 60, on: RunLoop.main, in: .default)
    temperature
        .sample(timer)
        .sink { temperature in print("The temperature is \(temperature)" }

Demo

rxmarbles/sample screenshot

Installation

Package.swift

Edit the Package.swift file. Add the SampledPublisher as a dependency:

let package = Package(
    name: " ... ",
    products: [ ... ],
    dependencies: [
        .package(url: "https://github.com/berikv/SampledPublisher.git", from: "1.0.0") // here
    ],
    targets: [
        .target(
            name: " ... ",
            dependencies: [
                "SampledPublisher" // and here
            ]),
    ]
)

For .xcodeproj projects

  1. Open menu File > Add Packages...
  2. Search for "https://github.com/berikv/SampledPublisher.git" and click Add Package.
  3. Open your project file, select your target in "Targets".
  4. Open Dependencies
  5. Click the + sign
  6. Add SampledPublisher
You might also like...
CloudKit Samples: Private Sync with Subscriptions and Push

CloudKit Samples: Private Sync with Subscriptions and Push Goals This project demonstrates using CloudKit Database Subscriptions and push notification

Firebase Quickstart Samples for iOS

Firebase Quickstarts for iOS A collection of quickstart samples demonstrating the Firebase APIs on iOS. Each sample contains targets for both Objectiv

Delightful console output for Swift developers.
Delightful console output for Swift developers.

Rainbow adds text color, background color and style for console and command line output in Swift. It is born for cross-platform software logging in te

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.

A lightweight Swift logger, uses `print` in development and `NSLog` in production. Support colourful and formatted output.
A lightweight Swift logger, uses `print` in development and `NSLog` in production. Support colourful and formatted output.

Loggerithm A lightweight Swift logger, uses print in Debug and NSLog in Production with colourful output. Why In Swift, we usually use print to log in

Measure the power output from a car or any moving vehicle from GPS data and weight
Measure the power output from a car or any moving vehicle from GPS data and weight

GPSDyno Measure the power output from a car or any moving vehicle from weight and GPS data of your iOS device. This is just a example project and shou

A simple framework to output to a file, url, the console, or even register notification using UserNotifications

o is a simple framework to output to a file, url, the console, or even register notification using UserNotifications. o can also get input from a file, url, or console.

Sample implementation of HDMI Clean out for iPhone or iPad video output.
Sample implementation of HDMI Clean out for iPhone or iPad video output.

HDMIPassThroughSample Sample implementation of HDMI Clean out for iPhone or iPad video output. "Lightning - Digital AV Adapter" can be used to output

LinkedLog is a Xcode plugin that includes a Xcode PCH header file template that adds the macros `LLog` and `LLogF` and parses their output to link from the console to the corresponding file and line.
LinkedLog is a Xcode plugin that includes a Xcode PCH header file template that adds the macros `LLog` and `LLogF` and parses their output to link from the console to the corresponding file and line.

LinkedLog Xcode Plugin LinkedLog is a Xcode plugin that includes a Xcode PCH file template that adds the macros LLog and LLogF. The LLog macro will wo

Jay - Pure-Swift JSON parser & formatter. Fully streamable input and output. Linux & OS X ready.

Pure-Swift JSON parser & formatter. Fully streamable input and output. Linux & OS X ready. Replacement for NSJSONSerialization.

Weather forecast app that allows the user to either look for weather at their current location based on the GPS data or search for another city manually.
Weather forecast app that allows the user to either look for weather at their current location based on the GPS data or search for another city manually.

⛅️ Cloudy Weather forecast app that allows the user to either look for weather at their current location based on the GPS data or search for another c

Tech blog about Put Generic Protocol as Variable Type. How Combine Publisher put into AnyPublisher

How to Put Generic Protocol as Variable Type Have you ever put a Protocol on a variable? I believe you do. The Delegate pattern is using a lot in UIKi

Very simple Observable and Publisher implementation for iOS apps.

Very simple Observable and Publisher implementation for iOS apps.

Combine publisher bridges for UIKit
Combine publisher bridges for UIKit

Combine publisher bridges for UIKit

Add publisher to reachability

ReachabilityCombine Add publisher to Reachability for convenience. usage

Publisher Assignable

PublisherAssignable Often times with SwiftUI, we find ourselves trying to plug a

A micro-library for creating and observing events.

Signals Signals is a library for creating and observing events. It replaces delegates, actions and NSNotificationCenter with something much more power

ResponderChain is a library that passes events using the responder chain.

ResponderChain ResponderChain is a library that passes events using the responder chain.

Suppress mouse & keyboard events on MacOSX. Baby-proof my Mac!

Suppress mouse & keyboard events on MacOSX Catches all events (mouse, keyboard, everything), and either consumes them (locked state) or passes them th

Owner
Berik Visschers
Berik Visschers
Another is a tweak written in Logos and Objective-C to customize Apple's voice assistant - Siri.

Preview On screeen: In reality: English: Another Allows you to customize Siri. Only for Jailbreak users. Compiling Theos is required to compile the pr

Matthew 3 May 5, 2022
SwiftAudioPlayer - Swift-based audio player with AVAudioEngine as its base

SwiftAudioPlayer Swift-based audio player with AVAudioEngine as its base. Allows for: streaming online audio, playing local file, changing audio speed

null 417 Jan 7, 2023
:musical_keyboard: A simple iOS synthesiser powered by Pure Data. Based on the Korg Monotron Delay.

Monotone Delay A simple iOS Synthesizer based on Pure Data. You can see a short demo of the app on youtube. If you want to buy the app you can find it

Justus Kandzi 17 Oct 16, 2022
🅿️ PandoraPlayer is a lightweight music player for iOS, based on AudioKit and completely written in Swift.

Made by Applikey Solutions Find this project on Dribbble Table of Contents Purpose Features Supported OS & SDK Versions Installation Usage Demo Releas

Applikey Solutions 1.1k Dec 26, 2022
I'm trying to make Flutter based Audio Unit Extensions possible.

Flutter AUv3 Audio Unit Error Demo Motivation We are the developers of Audanika, a professional MIDI Controller app written in Flutter. Many of our us

Gabriel Gatzsche 0 Jan 5, 2022
An app to get you the latest and the trending news based on your location.

Newsline Link to APK : http://bit.ly/newslineapp Newsline is an android application made with flutter which makes use of NewsAPI.org to fetch and serv

Ayush Shekhar 19 Nov 11, 2022
Leverages Apple's Swift-based Markdown parser to output NSAttributedString.

Markdownosaur ?? Markdownosaur uses Apple's excellent and relatively new Swift Markdown library to analyze a Markdown source, and then takes that anal

Christian Selig 232 Dec 20, 2022
Explanations and samples about the Swift programming language

About Swift Contents Explanations and samples about: Swift Programming Language Swift Standard Library Target audience Developers familiar with object

Nicola Lancellotti - About 74 Dec 29, 2022
Repository with base samples for playing HLS/DASH with CMAF video, across as many platforms as possible. Includes steps for encoding and packaging your own test content.

Video Everything Repository with minimal samples for playing HLS/DASH with CMAF video, across as many platforms as possible. Content and License All t

Alex Dodge 3 Jul 4, 2021
Useful Swift code samples, extensions, functionalities and scripts to cherry-pick and use in your projects

SwiftyPick ?? ?? Useful Swift code samples, extensions, functionalities and scripts to cherry-pick and use in your projects. Purpose The idea behind t

Manu Herrera 19 May 12, 2022