Skip to content

Commit

Permalink
Adding docs for togglePresence
Browse files Browse the repository at this point in the history
  • Loading branch information
mergesort committed Dec 29, 2023
1 parent c9044d7 commit 6cf5a88
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/Boutique/StoredValue+Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public extension StoredValue where Item: RangeReplaceableCollection {
}

@MainActor
/// A function that takes a value and removes it from an array if that value exists in the array,
/// or adds it to the array if the value doesn't exist.
/// - Parameter value: The value to add or remove from an array.
func togglePresence<Value: Equatable>(_ value: Value) where Item == [Value] {
var updatedArray = self.wrappedValue
updatedArray.togglePresence(value)
Expand Down Expand Up @@ -76,7 +79,11 @@ public extension AsyncStoredValue where Item: RangeReplaceableCollection {
try await self.set(updatedArray)
}


@MainActor
/// A function that takes a value and removes it from an array if that value exists in the array,
/// or adds it to the array if the value doesn't exist.
/// - Parameter value: The value to add or remove from an array.
func togglePresence<Value: Equatable>(_ value: Value) async throws where Item == [Value] {
var updatedArray = self.wrappedValue
updatedArray.togglePresence(value)
Expand Down

0 comments on commit 6cf5a88

Please sign in to comment.