Skip to content

Commit

Permalink
Make DelayedPromise conform to Equatable
Browse files Browse the repository at this point in the history
Fixes #37.
  • Loading branch information
lilyball committed Apr 27, 2019
1 parent d944b74 commit b9d97e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,12 @@ Unless you explicitly state otherwise, any contribution intentionally submitted

## Version History

### Development

- Make `DelayedPromise` conform to `Equatable` ([#37][]).

[#37]: https://github.com/lilyball/Tomorrowland/issues/37 "DelayedPromise should conform to Equatable"

### v0.5.1

- When chaining multiple `.main` context blocks in the same runloop pass, ensure we release each block before executing the next one.
Expand Down
7 changes: 6 additions & 1 deletion Sources/DelayedPromise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public typealias StdDelayedPromise<Value> = DelayedPromise<Value,Swift.Error>
/// avatar.promise.then { [weak self] (image) in
/// self?.imageView.image = image
/// }
public struct DelayedPromise<Value,Error> {
public struct DelayedPromise<Value,Error>: Equatable {
/// The type of the promise resolver. See `Promise<Value,Error>.Resolver`.
public typealias Resolver = Promise<Value,Error>.Resolver

Expand Down Expand Up @@ -64,6 +64,11 @@ public struct DelayedPromise<Value,Error> {
public var promise: Promise<Value,Error> {
return _box.toPromise(with: _seal)
}

/// Two `DelayedPromise`s compare as equal if they would produce equal `Promise`s.
public static func ==(lhs: DelayedPromise, rhs: DelayedPromise) -> Bool {
return lhs._box === rhs._box
}
}

// MARK: -
Expand Down

0 comments on commit b9d97e2

Please sign in to comment.