Skip to content

Commit

Permalink
Remove subscribable value from hash (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
tahirmt authored Feb 27, 2024
1 parent a629cea commit fc05979
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/Fisticuffs/Subscribable+Hashable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ extension Subscribable: Equatable where Value: Hashable {

extension Subscribable: Hashable where Value: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(currentValue)
// The hash does not include `currentValue` because for Subscribable
// values they will likely change during the lifecycle of an object
// and the hash value is not maintained constant. This can lead to unexpected
// behavior where a stable hash value is expected. e.g using the object as
// a key for a dictionary.
}
}

0 comments on commit fc05979

Please sign in to comment.