  observableProto.finalValue = function () {
    var source = this;
    return new AnonymousObservable(function (observer) {
      var hasValue = false, value;
      return source.subscribe(function (x) {
        hasValue = true;
        value = x;
      }, observer.onError.bind(observer), function () {
        if (!hasValue) {
          observer.onError(new Error(sequenceContainsNoElements));
        } else {
          observer.onNext(value);
          observer.onCompleted();
        }
      });
    });
  };
