<commit_before>//
//  NSNotificationCenter+Rx.swift
//  RxCocoa
//
//  Created by <NAME> on 5/2/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

extension Reactive where Base: NotificationCenter {
    /**
    Transforms notifications posted to notification center to observable sequence of notifications.
    
    - parameter name: Filter notifications by name.
    - parameter object: Optional object used to filter notifications.
    - returns: Observable sequence of posted notifications.
    */
    public func notification(_ name: Notification.Name, object: AnyObject? = nil) -> Observable<Notification> {
        return Observable.create { [weak object] observer in
            let nsObserver = self.base.addObserver(forName: name, object: object, queue: nil) { notification in
                observer.on(.next(notification))
            }
            
            return Disposables.create {
                self.base.removeObserver(nsObserver)
            }
        }
    }
}<commit_msg>Allow nil Notification.Name<commit_after>//
//  NSNotificationCenter+Rx.swift
//  RxCocoa
//
//  Created by <NAME> on 5/2/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif

extension Reactive where Base: NotificationCenter {
    /**
    Transforms notifications posted to notification center to observable sequence of notifications.
    
    - parameter name: Filter notifications by name.
    - parameter object: Optional object used to filter notifications.
    - returns: Observable sequence of posted notifications.
    */
    public func notification(_ name: Notification.Name?, object: AnyObject? = nil) -> Observable<Notification> {
        return Observable.create { [weak object] observer in
            let nsObserver = self.base.addObserver(forName: name, object: object, queue: nil) { notification in
                observer.on(.next(notification))
            }
            
            return Disposables.create {
                self.base.removeObserver(nsObserver)
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08866075594960336, 'fraction_numerical': 0.007466168922071862, 'mean_word_length': 2.537953795379538, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '2487278', 'n_tokens_mistral': 570, 'n_tokens_neox': 527, 'n_words': 176}