 import RxSwift
 import RxCocoa
 
-/// A get-only `Variable` that is equivalent to ReactiveSwift's `Property`.
+/// A get-only `BehaviorRelay` that works similar to ReactiveSwift's `Property`.
 ///
 /// - Note:
-/// This will send `.completed` when deallocated, just like `Variable` but not like `BehaviorRelay`.
-/// Thus, this class doesn't conform to `ObservableConvertibleType` for avoiding this being captured accidentally.
+/// From ver 0.3.0, this class will no longer send `.completed` when deallocated.
 ///
 /// - SeeAlso:
 ///     https://github.com/ReactiveCocoa/ReactiveSwift/blob/1.1.0/Sources/Property.swift

    /// - Warning:
    /// If `unsafeObservable` sends multiple values synchronously,
    /// the last value will be treated as initial value of `Property`.
    public init(unsafeObservable: Observable<E>) {
        let disposeBag = DisposeBag()
        _disposeBag = disposeBag

        let observable = unsafeObservable.share(replay: 1, scope: .whileConnected)
        var initial: E? = nil

        observable
            .subscribe(onNext: { initial = $0 })
            .disposed(by: disposeBag)

        guard let initial_ = initial else {
            fatalError("An unsafeObservable promised to send at least one value. Received none.")
        }

        _variable = Variable(initial_)

        observable
            .bind(to: _variable)
            .disposed(by: disposeBag)
    }

    /// Initializes with `initial` element and then `observable`.

        let disposeBag = DisposeBag()
        _disposeBag = disposeBag

        _behaviorRelay = BehaviorRelay(value: initial)

        observable
            .bind(to: _behaviorRelay)
            .disposed(by: disposeBag)
    }

    /// Observable that synchronously sends current element and then changed elements.
    /// This is same as `ReactiveSwift.Property<T>.producer`.
    public func asObservable() -> Observable<E> {
        return _behaviorRelay.asObservable()
    }

    /// Observable that only sends changed elements, ignoring current element.
