combine_pipeline.swift

Swiftマスター

Explorer

C40
C++40
C#40
Dart40
Go40
Java40
JavaScript40
Kotlin40
Objective-C40
Perl40
PHP40
Python40
R40
Ruby40
Rust40
Shell40
Swift
初級10
中級10
上級10
エキスパート5
マスター5
actor_isolation.swift
property_wrapper.swift
result_builder.swift
async_sequence.swift
combine_pipeline.swift
TypeScript40
combine_pipeline.swift
Click to focus
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class DataPipeline {
   @Published var output: [Result] = []
   private var cancellables = Set<AnyCancellable>()
   func setup(input: AnyPublisher<Data, Never>) {
       input
           .debounce(for: .milliseconds(300), scheduler: RunLoop.main)
           .compactMap { try? JSONDecoder().decode([Item].self, from: $0) }
           .flatMap { Publishers.Sequence(sequence: $0) }
           .collect()
           .sink { [weak self] in self?.output = $0.map(Result.init) }
           .store(in: &cancellables)
   }
}
0WPM0%0:000/518(0%)|Ln 1, Col 1
UTF-8Swift

関連する練習問題