Skip to content

Commit

Permalink
Adding back Store.Operation.add functions that were accidentally depr…
Browse files Browse the repository at this point in the history
…ecated
  • Loading branch information
mergesort committed Nov 4, 2022
1 parent 3dd4609 commit b5b697d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
34 changes: 33 additions & 1 deletion Sources/Boutique/Store.Operation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ public extension Store {
self.store = store
}

/// Adds an item to the ``Store``.
///
/// When an item is inserted with the same `cacheIdentifier` as an item that already exists in the ``Store``
/// the item being inserted will replace the item in the ``Store``. You can think of the ``Store`` as a bag
/// of items, removing complexity when it comes to managing items, indices, and more,
/// but it also means you need to choose well thought out and uniquely identifying `cacheIdentifier`s.
/// - Parameters:
/// - item: The item you are adding to the ``Store``.
@available(
*, deprecated,
renamed: "insert",
message: "This method is functionally equivalent to `insert` and will be removed in a future release. After using Boutique in practice for a while I decided that insert was a more semantically correct name for this operation on a Store, if you'd like to learn more you can see the discussion here. https://github.com/mergesort/Boutique/discussions/36"
)
public func add(_ item: Item) async throws -> Operation {
try await self.insert(item)
}

/// Inserts an item into the ``Store``.
///
/// When an item is inserted with the same `cacheIdentifier` as an item that already exists in the ``Store``
Expand Down Expand Up @@ -47,7 +64,22 @@ public extension Store {
return self
}

/// Inserts an array of items to the ``Store``.
/// Adds an array of items to the ``Store``.
///
/// Prefer inserting multiple items using this method instead of calling ``insert(_:)-1nu61``
/// multiple times to avoid making multiple separate dispatches to the `@MainActor`.
/// - Parameters:
/// - items: The items to add to the store.
@available(
*, deprecated,
renamed: "insert",
message: "This method is functionally equivalent to `insert` and will be removed in a future release. After using Boutique in practice for a while I decided that insert was a more semantically correct name for this operation on a Store, if you'd like to learn more you can see the discussion here. https://github.com/mergesort/Boutique/discussions/36"
)
public func add(_ items: [Item]) async throws -> Operation {
try await self.insert(items)
}

/// Inserts an array of items into the ``Store``.
///
/// Prefer inserting multiple items using this method instead of calling ``insert(_:)-1nu61``
/// multiple times to avoid making multiple separate dispatches to the `@MainActor`.
Expand Down
8 changes: 4 additions & 4 deletions Sources/Boutique/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public final class Store<Item: Codable & Equatable>: ObservableObject {
@available(
*, deprecated,
renamed: "insert",
message: "This method is functionally equivalent to `insert` and will be removed in v3. After using Boutique in practice for a while I decided that insert was a more semantically correct name for this operation on a Store, if you'd like to learn more you can see the discussion here. https://github.com/mergesort/Boutique/discussions/36"
message: "This method is functionally equivalent to `insert` and will be removed in a future release. After using Boutique in practice for a while I decided that insert was a more semantically correct name for this operation on a Store, if you'd like to learn more you can see the discussion here. https://github.com/mergesort/Boutique/discussions/36"
)
public func add(_ item: Item) async throws -> Operation {
let operation = Operation(store: self)
Expand Down Expand Up @@ -123,7 +123,7 @@ public final class Store<Item: Codable & Equatable>: ObservableObject {
@available(
*, deprecated,
renamed: "insert",
message: "This method is functionally equivalent to `insert` and will be removed in v3. After using Boutique in practice for a while I decided that insert was a more semantically correct name for this operation on a Store, if you'd like to learn more you can see the discussion here. https://github.com/mergesort/Boutique/discussions/36"
message: "This method is functionally equivalent to `insert` and will be removed in a future release. After using Boutique in practice for a while I decided that insert was a more semantically correct name for this operation on a Store, if you'd like to learn more you can see the discussion here. https://github.com/mergesort/Boutique/discussions/36"
)
public func add(_ item: Item) async throws {
try await self.performInsert(item)
Expand Down Expand Up @@ -152,7 +152,7 @@ public final class Store<Item: Codable & Equatable>: ObservableObject {
@available(
*, deprecated,
renamed: "insert",
message: "This method is functionally equivalent to `insert` and will be removed in v3. After using Boutique in practice for a while I decided that insert was a more semantically correct name for this operation on a Store, if you'd like to learn more you can see the discussion here. https://github.com/mergesort/Boutique/discussions/36"
message: "This method is functionally equivalent to `insert` and will be removed in a future release. After using Boutique in practice for a while I decided that insert was a more semantically correct name for this operation on a Store, if you'd like to learn more you can see the discussion here. https://github.com/mergesort/Boutique/discussions/36"
)
public func add(_ items: [Item]) async throws -> Operation {
let operation = Operation(store: self)
Expand Down Expand Up @@ -181,7 +181,7 @@ public final class Store<Item: Codable & Equatable>: ObservableObject {
@available(
*, deprecated,
renamed: "insert",
message: "This method is functionally equivalent to `insert` and will be removed in v3. After using Boutique in practice for a while I decided that insert was a more semantically correct name for this operation on a Store, if you'd like to learn more you can see the discussion here. https://github.com/mergesort/Boutique/discussions/36"
message: "This method is functionally equivalent to `insert` and will be removed in a future release. After using Boutique in practice for a while I decided that insert was a more semantically correct name for this operation on a Store, if you'd like to learn more you can see the discussion here. https://github.com/mergesort/Boutique/discussions/36"
)
public func add(_ items: [Item]) async throws {
try await self.performInsert(items)
Expand Down

0 comments on commit b5b697d

Please sign in to comment.