def __init__(self,name): ''' Constructor ''' Observer.__init__(self) self.name=name self.outputStream = Subject()
def subscribe(self, observerOrOnNext=noop, onError=noop, onComplete=noop): observer = observerOrOnNext if observerOrOnNext == None or callable(observerOrOnNext): observer = Observer.create(observerOrOnNext, onError, onComplete) return self.subscribeCore(observer)
def subscribe(self, observerOrOnNext=noop, onError=noop, onComplete=noop): observer = observerOrOnNext if observerOrOnNext == None or hasattr(observerOrOnNext, '__call__'): observer = Observer.create(observerOrOnNext, onError, onComplete) autoDetachObserver = AutoDetachObserver(observer) if Scheduler.currentThread.isScheduleRequired(): Scheduler.currentThread.scheduleWithState(autoDetachObserver, self.scheduledSubscribe) else: try: autoDetachObserver.disposable(self.subscribeCore(autoDetachObserver)) except Exception as e: if not autoDetachObserver.fail(e): raise e return autoDetachObserver
def synchronize(subject, scheduler=None): if scheduler == None: return AnonymousSubject(Observer.synchronize(subject), subject) else: return AnonymousSubject(Observer.synchronize(subject), subject.observeOn(scheduler))
def __init__(self,name): Observer.__init__(self)