Skip to content

Commit 35b5072

Browse files
authored
Allow async onCreatePublication callbacks (#673)
1 parent 19d03a4 commit 35b5072

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ All notable changes to this project will be documented in this file. Take a look
1313
* This callback is called before executing any navigation action.
1414
* Useful for hiding UI elements when the user navigates, or implementing analytics.
1515

16+
### Changed
17+
18+
#### Streamer
19+
20+
* Support for asynchronous callbacks with `onCreatePublication` (contributed by [@smoores-dev](https://github.com/readium/swift-toolkit/pull/673)).
21+
1622

1723
## [3.5.0]
1824

Sources/Shared/Publication/Publication.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public class Publication: Closeable, Loggable {
169169
_ manifest: inout Manifest,
170170
_ container: inout Container,
171171
_ services: inout PublicationServicesBuilder
172-
) -> Void
172+
) async -> Void
173173

174174
private var manifest: Manifest
175175
private var container: Container
@@ -185,12 +185,12 @@ public class Publication: Closeable, Loggable {
185185
self.servicesBuilder = servicesBuilder
186186
}
187187

188-
public mutating func apply(_ transform: Transform?) {
188+
public mutating func apply(_ transform: Transform?) async {
189189
guard let transform = transform else {
190190
return
191191
}
192192

193-
transform(&manifest, &container, &servicesBuilder)
193+
await transform(&manifest, &container, &servicesBuilder)
194194
}
195195

196196
/// Builds the `Publication` from its parts.

Sources/Streamer/PublicationOpener.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class PublicationOpener {
9393
switch await parser.parse(asset: asset, warnings: warnings) {
9494
case var .success(builder):
9595
for transform in builderTransforms {
96-
builder.apply(transform)
96+
await builder.apply(transform)
9797
}
9898
return .success(builder.build())
9999

0 commit comments

Comments
 (0)