72a1fad78e
* Add props * add props (iOS) * Add use-cases conditionally * Update CameraView+RecordVideo.swift * Update RecordingSession.swift * reconfigure on change * Throw correct errors * Check for audio permission * Move `#if` outward * Throw appropriate errors * Update CameraView+RecordVideo.swift * fix Splashscreen * Dynamic filePath * Fix video extension * add `avci` and `m4v` file types * Fix RecordVideo errors * Fix audio setup * Enable `photo`, `video` and `audio` * Check for `video={true}` in frameProcessor * format * Remove unused DispatchQueue * Update docs * Add `supportsPhotoAndVideoCapture` * Fix view manager * Fix error not being propagated * Catch normal errors too * Update DEVICES.mdx * Update CAPTURING.mdx * Update classdocs
39 lines
724 B
Swift
39 lines
724 B
Swift
//
|
|
// Callback.swift
|
|
// VisionCamera
|
|
//
|
|
// Created by Marc Rousavy on 07.06.21.
|
|
// Copyright © 2021 mrousavy. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
/**
|
|
Represents a callback to JavaScript. Syntax is the same as with Promise.
|
|
*/
|
|
class Callback {
|
|
init(_ callback: @escaping RCTResponseSenderBlock) {
|
|
self.callback = callback
|
|
}
|
|
|
|
func reject(error: CameraError, cause: NSError?) {
|
|
callback([NSNull(), makeReactError(error, cause: cause)])
|
|
}
|
|
|
|
func reject(error: CameraError) {
|
|
reject(error: error, cause: nil)
|
|
}
|
|
|
|
func resolve(_ value: Any?) {
|
|
callback([value, NSNull()])
|
|
}
|
|
|
|
func resolve() {
|
|
resolve(nil)
|
|
}
|
|
|
|
// MARK: Private
|
|
|
|
private let callback: RCTResponseSenderBlock
|
|
}
|