summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/RelaySelector+RelayCache.swift
blob: 3fd30180a558145fc0c56af2c2af52971a8e2185 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//
//  RelaySelector+RelayCache.swift
//  MullvadVPN
//
//  Created by pronebird on 07/11/2019.
//  Copyright © 2019 Mullvad VPN AB. All rights reserved.
//

import Combine
import Foundation

extension RelaySelector {

    static func loadedFromRelayCache() -> AnyPublisher<RelaySelector, RelayCacheError> {
        return RelayCache.withDefaultLocationAndEphemeralSession().publisher
            .flatMap { $0.read() }
            .map { RelaySelector(relayList: $0.relayList) }
            .eraseToAnyPublisher()
    }

}