in HuggingSnap/ContentViewModel.swift [27:62]
func setupSubscriptions() {
// swiftlint:disable:next array_init
cameraManager.$error
.receive(on: RunLoop.main)
.map { $0 }
.assign(to: &$error)
frameManager.$current
.receive(on: RunLoop.main)
.compactMap { buffer in
guard let image = CGImage.create(from: buffer) else {
return nil
}
let ciImage = CIImage(cgImage: image)
return self.context.createCGImage(ciImage, from: ciImage.extent)
}
.assign(to: &$frame)
cameraManager.$isRecording
.receive(on: RunLoop.main)
.assign(to: &$isRecording)
cameraManager.$isStreamingPaused
.receive(on: RunLoop.main)
.assign(to: &$isStreamingPaused)
cameraManager.$photo
.receive(on: RunLoop.main)
.assign(to: &$photo)
cameraManager.$movieURL
.receive(on: RunLoop.main)
.assign(to: &$movieURL)
}