@Override public synchronized void cancel() { switch (state.get()) { case ACTIVE: try { activeCall.cancel(); apolloStore.unsubscribe(recordChangeSubscriber); } finally { tracker.unregisterQueryWatcher(this); originalCallback.set(null); state.set(CANCELED); } break; case IDLE: state.set(CANCELED); break; case CANCELED: case TERMINATED: // These are not illegal states, but cancelling does nothing break; default: throw new IllegalStateException("Unknown state"); } }
@Override public synchronized void refetch() { switch (state.get()) { case ACTIVE: apolloStore.unsubscribe(recordChangeSubscriber); activeCall.cancel(); activeCall = activeCall.clone().responseFetcher(refetchResponseFetcher); activeCall.enqueue(callbackProxy()); break; case IDLE: throw new IllegalStateException("Cannot refetch a watcher which has not first called enqueueAndWatch."); case CANCELED: throw new IllegalStateException("Cannot refetch a canceled watcher,"); case TERMINATED: throw new IllegalStateException("Cannot refetch a watcher which has experienced an error."); default: throw new IllegalStateException("Unknown state"); } }
public synchronized void unsubscribe(ApolloStore.RecordChangeSubscriber subscriber) { mStore.unsubscribe(subscriber); }
@Override public synchronized void cancel() { switch (state.get()) { case ACTIVE: try { activeCall.cancel(); mApolloStore.unsubscribe(recordChangeSubscriber); } finally { tracker.unregisterQueryWatcher(this); originalCallback.set(null); state.set(CANCELED); } break; case IDLE: state.set(CANCELED); break; case CANCELED: case TERMINATED: // These are not illegal states, but cancelling does nothing break; default: throw new IllegalStateException("Unknown state"); } }
@Override public synchronized void cancel() { switch (state.get()) { case ACTIVE: try { activeCall.cancel(); mApolloStore.unsubscribe(recordChangeSubscriber); } finally { tracker.unregisterQueryWatcher(this); originalCallback.set(null); state.set(CANCELED); } break; case IDLE: state.set(CANCELED); break; case CANCELED: case TERMINATED: // These are not illegal states, but cancelling does nothing break; default: throw new IllegalStateException("Unknown state"); } }
@Override public synchronized void refetch() { switch (state.get()) { case ACTIVE: mApolloStore.unsubscribe(recordChangeSubscriber); activeCall.cancel(); activeCall = activeCall.clone().responseFetcher(refetchResponseFetcher); activeCall.enqueue(callbackProxy()); break; case IDLE: throw new IllegalStateException("Cannot refetch a watcher which has not first called enqueueAndWatch."); case CANCELED: throw new IllegalStateException("Cannot refetch a canceled watcher,"); case TERMINATED: throw new IllegalStateException("Cannot refetch a watcher which has experienced an error."); default: throw new IllegalStateException("Unknown state"); } }
@Override public synchronized void refetch() { switch (state.get()) { case ACTIVE: mApolloStore.unsubscribe(recordChangeSubscriber); activeCall.cancel(); activeCall = activeCall.clone().responseFetcher(refetchResponseFetcher); activeCall.enqueue(callbackProxy()); break; case IDLE: throw new IllegalStateException("Cannot refetch a watcher which has not first called enqueueAndWatch."); case CANCELED: throw new IllegalStateException("Cannot refetch a canceled watcher,"); case TERMINATED: throw new IllegalStateException("Cannot refetch a watcher which has experienced an error."); default: throw new IllegalStateException("Unknown state"); } }