Skip to content

Commit 7c7eb75

Browse files
committed
Separate PipelineSource and RealtimePipelineSource
1 parent 18fbbae commit 7c7eb75

File tree

3 files changed

+62
-14
lines changed

3 files changed

+62
-14
lines changed

Firestore/Swift/Source/SwiftAPI/Firestore+Pipeline.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import Foundation
2323

2424
@objc public extension Firestore {
2525
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
26-
@nonobjc func pipeline() -> PipelineSource<Pipeline> {
27-
return PipelineSource<Pipeline>(db: self) { stages, db in
26+
@nonobjc func pipeline() -> PipelineSource {
27+
return PipelineSource(db: self) { stages, db in
2828
Pipeline(stages: stages, db: db)
2929
}
3030
}
3131

3232
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
33-
@nonobjc internal func realtimePipeline() -> PipelineSource<RealtimePipeline> {
34-
return PipelineSource<RealtimePipeline>(db: self) { stages, db in
33+
@nonobjc internal func realtimePipeline() -> RealtimePipelineSource {
34+
return RealtimePipelineSource(db: self) { stages, db in
3535
RealtimePipeline(stages: stages, db: db)
3636
}
3737
}

Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineSource.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,44 @@
1313
// limitations under the License.
1414

1515
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
16-
public struct PipelineSource<P>: @unchecked Sendable {
16+
public struct PipelineSource: @unchecked Sendable {
1717
let db: Firestore
18-
let factory: ([Stage], Firestore) -> P
18+
let factory: ([Stage], Firestore) -> Pipeline
1919

20-
init(db: Firestore, factory: @escaping ([Stage], Firestore) -> P) {
20+
init(db: Firestore, factory: @escaping ([Stage], Firestore) -> Pipeline) {
2121
self.db = db
2222
self.factory = factory
2323
}
2424

25-
public func collection(_ path: String) -> P {
25+
public func collection(_ path: String) -> Pipeline {
2626
return factory([CollectionSource(collection: db.collection(path), db: db)], db)
2727
}
2828

29-
public func collection(_ coll: CollectionReference) -> P {
29+
public func collection(_ coll: CollectionReference) -> Pipeline {
3030
return factory([CollectionSource(collection: coll, db: db)], db)
3131
}
3232

33-
public func collectionGroup(_ collectionId: String) -> P {
33+
public func collectionGroup(_ collectionId: String) -> Pipeline {
3434
return factory(
3535
[CollectionGroupSource(collectionId: collectionId)],
3636
db
3737
)
3838
}
3939

40-
public func database() -> P {
40+
public func database() -> Pipeline {
4141
return factory([DatabaseSource()], db)
4242
}
4343

44-
public func documents(_ docs: [DocumentReference]) -> P {
44+
public func documents(_ docs: [DocumentReference]) -> Pipeline {
4545
return factory([DocumentsSource(docs: docs, db: db)], db)
4646
}
4747

48-
public func documents(_ paths: [String]) -> P {
48+
public func documents(_ paths: [String]) -> Pipeline {
4949
let docs = paths.map { db.document($0) }
5050
return factory([DocumentsSource(docs: docs, db: db)], db)
5151
}
5252

53-
public func create(from query: Query) -> P {
53+
public func create(from query: Query) -> Pipeline {
5454
let stageBridges = PipelineBridge.createStageBridges(from: query)
5555
let stages: [Stage] = stageBridges.map { bridge in
5656
switch bridge.name {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
16+
internal struct RealtimePipelineSource: @unchecked Sendable {
17+
let db: Firestore
18+
let factory: ([Stage], Firestore) -> RealtimePipeline
19+
20+
init(db: Firestore, factory: @escaping ([Stage], Firestore) -> RealtimePipeline) {
21+
self.db = db
22+
self.factory = factory
23+
}
24+
25+
internal func collection(_ path: String) -> RealtimePipeline {
26+
return factory([CollectionSource(collection: db.collection(path), db: db)], db)
27+
}
28+
29+
internal func collection(_ coll: CollectionReference) -> RealtimePipeline {
30+
return factory([CollectionSource(collection: coll, db: db)], db)
31+
}
32+
33+
internal func collectionGroup(_ collectionId: String) -> RealtimePipeline {
34+
return factory(
35+
[CollectionGroupSource(collectionId: collectionId)],
36+
db
37+
)
38+
}
39+
40+
internal func documents(_ docs: [DocumentReference]) -> RealtimePipeline {
41+
return factory([DocumentsSource(docs: docs, db: db)], db)
42+
}
43+
44+
internal func documents(_ paths: [String]) -> RealtimePipeline {
45+
let docs = paths.map { db.document($0) }
46+
return factory([DocumentsSource(docs: docs, db: db)], db)
47+
}
48+
}

0 commit comments

Comments
 (0)