Files

39 lines
1.0 KiB
Swift

//
// NetworkService.swift
// Wallet
//
// Created by Igor on 05.03.2021.
// Copyright © 2021 AM. All rights reserved.
//
import Foundation
import Reachability
extension Notification.Name {
static let didUpdateReachability = Notification.Name("Network.Service.didUpdateReachability")
}
extension Network {
class Service: Common.Service.Provider {
let cities = Cities()
let balance = Balance()
let actions = Actions()
let table = Table()
let accounts = Accounts()
let webSockets = WebSockets()
let graphpql = GraphQL()
// swiftlint:disable force_try
private let reachability = try! Reachability()
var isReachable: Bool { reachability.connection != .unavailable }
init() {
reachability.whenReachable = { _ in Notification.post(name: .didUpdateReachability) }
reachability.whenUnreachable = { _ in Notification.post(name: .didUpdateReachability) }
try? reachability.startNotifier()
}
}
}