Skip to content

Commit d52a6f1

Browse files
committed
Update documentation.
1 parent d01941c commit d52a6f1

File tree

2 files changed

+98
-22
lines changed

2 files changed

+98
-22
lines changed

docs/reference/SQLiteWorkspace.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ public func performChanges(
6868

6969
### `performChanges(_:changesHandler:)`
7070

71+
```swift
72+
public func performChanges(
73+
_ transactionalObjectTypes: [Any.Type], changesHandler: @escaping ChangesHandler
74+
) async -> Bool
75+
```
76+
7177
Perform a transaction for given object types and await either success or failure boolean.
7278

7379
- Parameters:
@@ -91,10 +97,10 @@ public func fetchWithinASnapshot<T>(_ closure: () -> T) -> T
9197
### `subscribe(fetchedResult:changeHandler:)`
9298

9399
```swift
94-
public func subscribe<Element: Atom>(
100+
public func subscribe<Element: Atom & Equatable>(
95101
fetchedResult: FetchedResult<Element>,
96102
changeHandler: @escaping (_: FetchedResult<Element>) -> Void
97-
) -> Workspace.Subscription where Element: Equatable
103+
) -> Workspace.Subscription
98104
```
99105

100106
#### Parameters
@@ -107,9 +113,9 @@ public func subscribe<Element: Atom>(
107113
### `subscribe(object:changeHandler:)`
108114

109115
```swift
110-
public func subscribe<Element: Atom>(
116+
public func subscribe<Element: Atom & Equatable>(
111117
object: Element, changeHandler: @escaping (_: SubscribedObject<Element>) -> Void
112-
) -> Workspace.Subscription where Element: Equatable
118+
) -> Workspace.Subscription
113119
```
114120

115121
#### Parameters
@@ -122,22 +128,39 @@ public func subscribe<Element: Atom>(
122128
### `publisher(for:)`
123129

124130
```swift
125-
public func publisher<Element: Atom>(for object: Element) -> AtomPublisher<Element>
126-
where Element: Equatable
131+
public func publisher<Element: Atom & Equatable>(for object: Element) -> AtomPublisher<Element>
127132
```
128133

129134
### `publisher(for:)`
130135

131136
```swift
132-
public func publisher<Element: Atom>(for fetchedResult: FetchedResult<Element>)
133-
-> FetchedResultPublisher<Element> where Element: Equatable
137+
public func publisher<Element: Atom & Equatable>(for fetchedResult: FetchedResult<Element>)
138+
-> FetchedResultPublisher<Element>
134139
```
135140

136141
### `publisher(for:)`
137142

138143
```swift
139-
public func publisher<Element: Atom>(for: Element.Type) -> QueryPublisherBuilder<Element>
140-
where Element: Equatable
144+
public func publisher<Element: Atom & Equatable>(for: Element.Type) -> QueryPublisherBuilder<
145+
Element
146+
>
147+
```
148+
149+
### `subscribe(object:bufferingPolicy:)`
150+
151+
```swift
152+
public func subscribe<Element: Atom & Equatable>(
153+
object: Element, bufferingPolicy: AsyncStream<Element>.Continuation.BufferingPolicy
154+
) -> AsyncStream<Element>
155+
```
156+
157+
### `subscribe(fetchedResult:bufferingPolicy:)`
158+
159+
```swift
160+
public func subscribe<Element: Atom & Equatable>(
161+
fetchedResult: FetchedResult<Element>,
162+
bufferingPolicy: AsyncStream<FetchedResult<Element>>.Continuation.BufferingPolicy
163+
) -> AsyncStream<FetchedResult<Element>>
141164
```
142165

143166

docs/reference/Workspace.md

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ public protocol WorkspaceDictionary
3939
var keys: [String]
4040
```
4141

42-
Return all keys available in the dictionary. This is an expensive (for this dictionary)
43-
method as it fetches from disk, from in-memory structures, and acquire locks if needed.
42+
Return all keys available in the dictionary. This is an expensive (for this dictionary)
43+
method as it fetches from disk, from in-memory structures, and acquire locks if needed.
44+
45+
- Returns: List of all keys available at the point of time in persisted dictionary.
4446

4547
## Methods
4648
### `synchronize()`
@@ -131,6 +133,12 @@ func performChanges(
131133

132134
### `performChanges(_:changesHandler:)`
133135

136+
```swift
137+
func performChanges(
138+
_ transactionalObjectTypes: [Any.Type], changesHandler: @escaping ChangesHandler
139+
) async -> Bool
140+
```
141+
134142
Perform a transaction for given object types and await either success or failure boolean.
135143

136144
- Parameters:
@@ -142,10 +150,10 @@ func performChanges(
142150
### `subscribe(fetchedResult:changeHandler:)`
143151

144152
```swift
145-
func subscribe<Element: Atom>(
153+
func subscribe<Element: Atom & Equatable>(
146154
fetchedResult: FetchedResult<Element>,
147155
changeHandler: @escaping (_: FetchedResult<Element>) -> Void
148-
) -> Subscription where Element: Equatable
156+
) -> Subscription
149157
```
150158

151159
Subscribe to changes of a fetched result. You queries fetched result with
@@ -171,9 +179,9 @@ func subscribe<Element: Atom>(
171179
### `subscribe(object:changeHandler:)`
172180

173181
```swift
174-
func subscribe<Element: Atom>(
182+
func subscribe<Element: Atom & Equatable>(
175183
object: Element, changeHandler: @escaping (_: SubscribedObject<Element>) -> Void
176-
) -> Subscription where Element: Equatable
184+
) -> Subscription
177185
```
178186

179187
Subscribe to changes of an object. If anything in the object changed or
@@ -201,29 +209,61 @@ func subscribe<Element: Atom>(
201209
### `publisher(for:)`
202210

203211
```swift
204-
func publisher<Element: Atom>(for: Element) -> AtomPublisher<Element> where Element: Equatable
212+
func publisher<Element: Atom & Equatable>(for: Element) -> AtomPublisher<Element>
205213
```
206214

207215
Return a publisher for object subscription in Combine.
208216

209217
### `publisher(for:)`
210218

211219
```swift
212-
func publisher<Element: Atom>(for: FetchedResult<Element>) -> FetchedResultPublisher<Element>
213-
where Element: Equatable
220+
func publisher<Element: Atom & Equatable>(for: FetchedResult<Element>)
221+
-> FetchedResultPublisher<Element>
214222
```
215223

216224
Return a publisher for fetched result subscription in Combine.
217225

218226
### `publisher(for:)`
219227

220228
```swift
221-
func publisher<Element: Atom>(for: Element.Type) -> QueryPublisherBuilder<Element>
222-
where Element: Equatable
229+
func publisher<Element: Atom & Equatable>(for: Element.Type) -> QueryPublisherBuilder<Element>
223230
```
224231

225232
Return a publisher builder for query subscription in Combine.
226233

234+
### `subscribe(object:bufferingPolicy:)`
235+
236+
```swift
237+
func subscribe<Element: Atom & Equatable>(
238+
object: Element, bufferingPolicy: AsyncStream<Element>.Continuation.BufferingPolicy
239+
) -> AsyncStream<Element>
240+
```
241+
242+
Subscribe to changes to the said object, and return the AsyncSequence you can iterate over.
243+
244+
- Parameters:
245+
- object: The object previously fetched that we want to observe the new updates.
246+
- bufferingPolicy: The buffering policy to avoid issuing all updates to concerned parties. Default will be the newest of 1.
247+
248+
- Returns: An AsyncSequence that can await for new object updates. Finishes only if the object deletes.
249+
250+
### `subscribe(fetchedResult:bufferingPolicy:)`
251+
252+
```swift
253+
func subscribe<Element: Atom & Equatable>(
254+
fetchedResult: FetchedResult<Element>,
255+
bufferingPolicy: AsyncStream<FetchedResult<Element>>.Continuation.BufferingPolicy
256+
) -> AsyncStream<FetchedResult<Element>>
257+
```
258+
259+
Subscribe to changes to the said fetched result, and return the AsyncSequence you can iterate over.
260+
261+
- Parameters:
262+
- fetchedResult: The result fetched that we want to observe the new updates.
263+
- bufferingPolicy: The buffering policy to avoid issuing all updates to concerned parties. Default will be the newest of 1.
264+
265+
- Returns: An AsyncSequence that can await for new fetched result. It never finishes.
266+
227267

228268
**EXTENSION**
229269

@@ -247,6 +287,19 @@ public func performChanges(
247287
)
248288
```
249289

290+
### `subscribe(object:)`
291+
292+
```swift
293+
public func subscribe<Element: Atom & Equatable>(object: Element) -> AsyncStream<Element>
294+
```
295+
296+
### `subscribe(fetchedResult:)`
297+
298+
```swift
299+
public func subscribe<Element: Atom & Equatable>(fetchedResult: FetchedResult<Element>)
300+
-> AsyncStream<FetchedResult<Element>>
301+
```
302+
250303

251304
**CLASS**
252305

@@ -359,7 +412,7 @@ The object is deleted. This denotes the end of a subscription.
359412
# `QueryPublisherBuilder`
360413

361414
```swift
362-
open class QueryPublisherBuilder<Element: Atom> where Element: Equatable
415+
open class QueryPublisherBuilder<Element: Atom & Equatable>
363416
```
364417

365418
## Methods

0 commit comments

Comments
 (0)