Skip to content

Commit b35f145

Browse files
authored
Deprecate Refreshable and Resettable (#185)
1 parent 8fc14ac commit b35f145

16 files changed

+139
-38
lines changed

Sources/Atoms/Attribute/Refreshable.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/// }
2222
/// ```
2323
///
24+
@available(*, deprecated, message: "`Refreshable` is deprecated. Use a custom refresh function or other alternatives instead.")
2425
public protocol Refreshable where Self: Atom {
2526
/// Refreshes and then return a result value.
2627
///

Sources/Atoms/Attribute/Resettable.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/// }
2222
/// ```
2323
///
24+
@available(*, deprecated, message: "`Resettable` is deprecated. Use a custom reset function or other alternatives instead.")
2425
public protocol Resettable where Self: Atom {
2526
/// Arbitrary reset method to be executed on atom reset.
2627
///

Sources/Atoms/Context/AtomContext.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public protocol AtomContext {
9999
/// - Parameter atom: An atom to refresh.
100100
///
101101
/// - Returns: The value after the refreshing associated with the given atom is completed.
102+
@available(*, deprecated, message: "`Refreshable` is deprecated. Use a custom refresh function or other alternatives instead.")
102103
@discardableResult
103104
func refresh<Node: Refreshable>(_ atom: Node) async -> Node.Produced
104105

@@ -136,6 +137,7 @@ public protocol AtomContext {
136137
/// ```
137138
///
138139
/// - Parameter atom: An atom to reset.
140+
@available(*, deprecated, message: "`Resettable` is deprecated. Use a custom reset function or other alternatives instead.")
139141
func reset(_ atom: some Resettable)
140142
}
141143

Sources/Atoms/Context/AtomCurrentContext.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public struct AtomCurrentContext: AtomContext {
113113
/// - Parameter atom: An atom to refresh.
114114
///
115115
/// - Returns: The value after the refreshing associated with the given atom is completed.
116+
@available(*, deprecated, message: "`Refreshable` is deprecated. Use a custom refresh function or other alternatives instead.")
116117
@inlinable
117118
@discardableResult
118119
public func refresh<Node: Refreshable>(_ atom: Node) async -> Node.Produced {
@@ -155,6 +156,7 @@ public struct AtomCurrentContext: AtomContext {
155156
/// ```
156157
///
157158
/// - Parameter atom: An atom to reset.
159+
@available(*, deprecated, message: "`Resettable` is deprecated. Use a custom reset function or other alternatives instead.")
158160
@inlinable
159161
public func reset(_ atom: some Resettable) {
160162
_store.reset(atom)

Sources/Atoms/Context/AtomTestContext.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ public struct AtomTestContext: AtomWatchableContext {
257257
/// - Parameter atom: An atom to refresh.
258258
///
259259
/// - Returns: The value after the refreshing associated with the given atom is completed.
260+
@available(*, deprecated, message: "`Refreshable` is deprecated. Use a custom refresh function or other alternatives instead.")
260261
@inlinable
261262
@discardableResult
262263
public func refresh<Node: Refreshable>(_ atom: Node) async -> Node.Produced {
@@ -300,6 +301,7 @@ public struct AtomTestContext: AtomWatchableContext {
300301
/// ```
301302
///
302303
/// - Parameter atom: An atom to reset.
304+
@available(*, deprecated, message: "`Resettable` is deprecated. Use a custom reset function or other alternatives instead.")
303305
@inlinable
304306
public func reset(_ atom: some Resettable) {
305307
_store.reset(atom)

Sources/Atoms/Context/AtomTransactionContext.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public struct AtomTransactionContext: AtomWatchableContext {
123123
/// - Parameter atom: An atom to refresh.
124124
///
125125
/// - Returns: The value after the refreshing associated with the given atom is completed.
126+
@available(*, deprecated, message: "`Refreshable` is deprecated. Use a custom refresh function or other alternatives instead.")
126127
@inlinable
127128
@discardableResult
128129
public func refresh<Node: Refreshable>(_ atom: Node) async -> Node.Produced {
@@ -166,6 +167,7 @@ public struct AtomTransactionContext: AtomWatchableContext {
166167
/// ```
167168
///
168169
/// - Parameter atom: An atom to reset.
170+
@available(*, deprecated, message: "`Resettable` is deprecated. Use a custom reset function or other alternatives instead.")
169171
@inlinable
170172
public func reset(_ atom: some Resettable) {
171173
_store.reset(atom)

Sources/Atoms/Context/AtomViewContext.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public struct AtomViewContext: AtomWatchableContext {
129129
/// - Parameter atom: An atom to refresh.
130130
///
131131
/// - Returns: The value after the refreshing associated with the given atom is completed.
132+
@available(*, deprecated, message: "`Refreshable` is deprecated. Use a custom refresh function or other alternatives instead.")
132133
@inlinable
133134
@discardableResult
134135
public func refresh<Node: Refreshable>(_ atom: Node) async -> Node.Produced {
@@ -172,6 +173,7 @@ public struct AtomViewContext: AtomWatchableContext {
172173
/// ```
173174
///
174175
/// - Parameter atom: An atom to reset.
176+
@available(*, deprecated, message: "`Resettable` is deprecated. Use a custom reset function or other alternatives instead.")
175177
@inlinable
176178
public func reset(_ atom: some Resettable) {
177179
_store.reset(atom)

Sources/Atoms/Core/StoreContext.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ internal struct StoreContext {
158158
return value
159159
}
160160

161+
@available(*, deprecated)
161162
@usableFromInline
162163
func refresh<Node: Refreshable>(_ atom: Node) async -> Node.Produced {
163164
let (key, _) = lookupAtomKeyAndOverride(of: atom)
@@ -199,6 +200,7 @@ internal struct StoreContext {
199200
}
200201
}
201202

203+
@available(*, deprecated)
202204
@usableFromInline
203205
func reset(_ atom: some Resettable) {
204206
let (key, _) = lookupAtomKeyAndOverride(of: atom)

Tests/AtomsTests/Attribute/RefreshableTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import XCTest
22

33
@testable import Atoms
44

5+
@available(*, deprecated)
56
final class RefreshableTests: XCTestCase {
67
@MainActor
78
func testCustomRefresh() async {

Tests/AtomsTests/Attribute/ResettableTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import XCTest
22

33
@testable import Atoms
44

5+
@available(*, deprecated)
56
final class ResettableTests: XCTestCase {
67
@MainActor
78
func testCustomReset() {

0 commit comments

Comments
 (0)