Swiftpack.co -  AndrewSB/Expirable as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A Swift µ-Library for modeling and reacting to values that expire
.package(url: "https://github.com/AndrewSB/Expirable.git", from: "v1.0.0")


A Swift µ-Library for modeling and reacting to values that expire


I wrote this while dealing with a number of expiring values (nonces from a hardware device, OAuth tokens, command tokens to send to hardware) during my time at Proxy.

It's a one-file dependency that exposes an Expirable protocol. Once implemented by a object that models some data that becomes stale at some point in the future, you get a number of convienient ways to deal with and react to said data expiring


The package is available through

  • Swift package manager
  • Carthage
  • Manual copying of the one file

Sample usage

You can check out the Example.playground to see an example of the library in use. Make sure you carthage bootstrap and build the Expirable framework, the playground can't run without them.



The protocol exposed in this micro library, it expects two pieces of data

expiresAt: Date the date at which the data expires
expirationMarginInterval: TimeInterval an interval preceeding the expiry used to send a message of impending expiry
isValid: Bool

syncronous access to whether the object has expired

isExpiredOrExpiringSoon: Bool

syncronous access to whether the object has expired or is about to expire, based on subtracting the expirationMarginInterval from the expiresAt date

expiresSoon: Observable<Void>

an observable that will fire as soon as the current date is greater than expiresAt - expirationMarginInterval.


Stars: 10
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

RxSwift 3
4 years ago

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