# Path: rx/notification.py
# class Notification(object):
#   """Represents a notification to an observer."""
# 
#   KIND_NEXT = 0
#   KIND_ERROR = 1
#   KIND_COMPLETED = 2
# 
#   def __eq__(self, other):
#     if not isinstance(other, Notification):
#       return False
# 
#     return (
#       self.kind == other.kind and
#       self.value == other.value and
#       self.hasValue == other.hasValue and
#       self.exception == other.exception
#     )
# 
#   def accept(self, observerOrOnNext, onError=None, onCompleted=None):
#     """Accepts an observer or the methods onNext, onError, onCompleted and invokes
#     either onNext, onError, onCompleted depending on which type of :class:`Notification`
#     it is. This is an abstract method that is implemented by
#     :class:`OnNextNotification`, :class:`OnErrorNotification`,
#     and :class:`OnCompletedNotification`."""
#     # if observerOrOnNext == None or hasattr(observerOrOnNext, '__call__'):
#     #   observer = Observer.create(observerOrOnNext, onError, onComplete)
#     raise NotImplementedError()
# 
#   @staticmethod
#   def createOnNext(value):
#     return OnNextNotification(value)
# 
#   @staticmethod
#   def createOnError(exception):
#     return OnErrorNotification(exception)
# 
#   @staticmethod
#   def createOnCompleted():
#     return OnCompletedNotification()
# 
# Path: rx/observable.py
# class PushToPullAdapter(object):
#   def __init__(self, source):
#     self.source = source
# 
#   def __iter__(self):
#     d = SingleAssignmentDisposable()
#     res = self.run(d)
#     d.disposable = self.source.subscribeSafe(res)
#     return res
# 
#   def run(self, subscription):
#     raise NotImplementedError()


from rx.notification import Notification
from rx.observable import PushToPullAdapter
import rx.linq.sink
  class Sink(rx.linq.sink.PushToPullSink):
    def __init__(self, initialValue, subscription):
      super(MostRecent.Sink, self).__init__(subscription)
      self.kind = Notification.KIND_NEXT
      self.value = initialValue
      self.error = None

    def onNext(self, value):
      self.value = value
      self.kind = Notification.KIND_NEXT

    def onError(self, exception):
      self.dispose()

      self.error = exception
      self.kind = Notification.KIND_ERROR

    def onCompleted(self):
      self.dispose()

      self.kind = Notification.KIND_COMPLETED

    def tryMoveNext(self):
      kind = self.kind

      if kind == Notification.KIND_NEXT:
        self.current = self.value
        return True
      elif kind == Notification.KIND_ERROR:
        raise self.error

# Path: rx/notification.py
# class Notification(object):
#   """Represents a notification to an observer."""
# 
#   KIND_NEXT = 0
#   KIND_ERROR = 1
#   KIND_COMPLETED = 2
# 
#   def __eq__(self, other):
#     if not isinstance(other, Notification):
#       return False
# 
#     return (
#       self.kind == other.kind and
#       self.value == other.value and
#       self.hasValue == other.hasValue and
#       self.exception == other.exception
#     )
# 
#   def accept(self, observerOrOnNext, onError=None, onCompleted=None):
#     """Accepts an observer or the methods onNext, onError, onCompleted and invokes
#     either onNext, onError, onCompleted depending on which type of :class:`Notification`
#     it is. This is an abstract method that is implemented by
#     :class:`OnNextNotification`, :class:`OnErrorNotification`,
#     and :class:`OnCompletedNotification`."""
#     # if observerOrOnNext == None or hasattr(observerOrOnNext, '__call__'):
#     #   observer = Observer.create(observerOrOnNext, onError, onComplete)
#     raise NotImplementedError()
# 
#   @staticmethod
#   def createOnNext(value):
#     return OnNextNotification(value)
# 
#   @staticmethod
#   def createOnError(exception):
#     return OnErrorNotification(exception)
# 
#   @staticmethod
#   def createOnCompleted():
#     return OnCompletedNotification()
# 
# Path: rx/observable.py
# class PushToPullAdapter(object):
#   def __init__(self, source):
#     self.source = source
# 
#   def __iter__(self):
#     d = SingleAssignmentDisposable()
#     res = self.run(d)
#     d.disposable = self.source.subscribeSafe(res)
#     return res
# 
#   def run(self, subscription):
#     raise NotImplementedError()


# Path: rx/linq/mostRecent.py
from rx.notification import Notification
from rx.observable import PushToPullAdapter
import rx.linq.sink

  class Sink(rx.linq.sink.PushToPullSink):
    def __init__(self, initialValue, subscription):
      super(MostRecent.Sink, self).__init__(subscription)
      self.kind = Notification.KIND_NEXT
      self.value = initialValue
      self.error = None

    def onNext(self, value):
      self.value = value
      self.kind = Notification.KIND_NEXT

    def onError(self, exception):
      self.dispose()

      self.error = exception
      self.kind = Notification.KIND_ERROR

    def onCompleted(self):
      self.dispose()

      self.kind = Notification.KIND_COMPLETED

    def tryMoveNext(self):
      kind = self.kind

      if kind == Notification.KIND_NEXT:
        self.current = self.value
        return True
      elif kind == Notification.KIND_ERROR:
        raise self.error

      elif kind == Notification.KIND_COMPLETED: