Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
833 B
2
Indexable
/// - Parameter completion: NodeCompletion callback which returns the result of Node submission.
    public func next<T>(completion:@escaping NodeCompletion<T>) {

        if T.self as AnyObject? === Token.self {
            next { (token: Token?, node, error) in
                completion(token as? T, node, error)
            }
        }
        else if T.self as AnyObject? === AccessToken.self {
            next { (token: AccessToken?, node, error) in
                completion(token as? T, node, error)
            }
        }
        else if T.self as AnyObject? === FRUser.self {
            next { (user: FRUser?, node, error) in
                completion(user as? T, node, error)
            }
        }
        else {
            completion(nil, nil, AuthError.invalidGenericType)
        }
    }