<commit_before>import Foundation
import ReactiveSwift
#if !COCOAPODS
import Moya
#endif

/// Subclass of MoyaProvider that returns SignalProducer instances when requests are made. Much better than using completion closures.
open class ReactiveCocoaMoyaProvider<Target>: MoyaProvider<Target> where Target: TargetType {
    private let stubScheduler: DateSchedulerProtocol?
    /// Initializes a reactive provider.
    public init(endpointClosure: @escaping EndpointClosure = MoyaProvider.DefaultEndpointMapping,
        requestClosure: @escaping RequestClosure = MoyaProvider.DefaultRequestMapping,
        stubClosure: @escaping StubClosure = MoyaProvider.NeverStub,
        manager: Manager = ReactiveCocoaMoyaProvider<Target>.DefaultAlamofireManager(),
        plugins: [PluginType] = [], stubScheduler: DateSchedulerProtocol? = nil,
        trackInflights: Bool = false) {
            self.stubScheduler = stubScheduler
            super.init(endpointClosure: endpointClosure, requestClosure: requestClosure, stubClosure: stubClosure, manager: manager, plugins: plugins, trackInflights: trackInflights)
    }

    /// Designated request-making method.
    public func request(token: Target) -> SignalProducer<Response, Moya.Error> {

        // Creates a producer that starts a request each time it's started.
        return SignalProducer { [weak self] observer, requestDisposable in
            let cancellableToken = self?.request(token) { result in
                switch result {
                case let .success(response):
                    observer.send(value: response)
                    observer.sendCompleted()
                case let .failure(error):
                    observer.send(error: error)
                }
            }

            requestDisposable.add {
                // Cancel the request
                cancellableToken?.cancel()
            }
        }
    }<commit_msg>Match ReactiveCocoa `func request(_)` access level to that of RxSwift<commit_after>import Foundation
import ReactiveSwift
#if !COCOAPODS
import Moya
#endif

/// Subclass of MoyaProvider that returns SignalProducer instances when requests are made. Much better than using completion closures.
open class ReactiveCocoaMoyaProvider<Target>: MoyaProvider<Target> where Target: TargetType {
    private let stubScheduler: DateSchedulerProtocol?
    /// Initializes a reactive provider.
    public init(endpointClosure: @escaping EndpointClosure = MoyaProvider.DefaultEndpointMapping,
        requestClosure: @escaping RequestClosure = MoyaProvider.DefaultRequestMapping,
        stubClosure: @escaping StubClosure = MoyaProvider.NeverStub,
        manager: Manager = ReactiveCocoaMoyaProvider<Target>.DefaultAlamofireManager(),
        plugins: [PluginType] = [], stubScheduler: DateSchedulerProtocol? = nil,
        trackInflights: Bool = false) {
            self.stubScheduler = stubScheduler
            super.init(endpointClosure: endpointClosure, requestClosure: requestClosure, stubClosure: stubClosure, manager: manager, plugins: plugins, trackInflights: trackInflights)
    }

    /// Designated request-making method.
    open func request(token: Target) -> SignalProducer<Response, Moya.Error> {

        // Creates a producer that starts a request each time it's started.
        return SignalProducer { [weak self] observer, requestDisposable in
            let cancellableToken = self?.request(token) { result in
                switch result {
                case let .success(response):
                    observer.send(value: response)
                    observer.sendCompleted()
                case let .failure(error):
                    observer.send(error: error)
                }
            }

            requestDisposable.add {
                // Cancel the request
                cancellableToken?.cancel()
            }
        }
    }
{'fraction_non_alphanumeric': 0.0743417656169334, 'fraction_numerical': 0.0, 'mean_word_length': 2.718809980806142, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7140897', 'n_tokens_mistral': 1021, 'n_tokens_neox': 947, 'n_words': 267}