com.apollographql.apollo3.runtime.java.internal.DefaultApolloDisposable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo-runtime-java Show documentation
Show all versions of apollo-runtime-java Show documentation
Apollo GraphQL runtime for Java
package com.apollographql.apollo3.runtime.java.internal;
import com.apollographql.apollo3.runtime.java.ApolloDisposable;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
public class DefaultApolloDisposable implements ApolloDisposable {
private AtomicBoolean isDisposed = new AtomicBoolean(false);
private ArrayList listeners = new ArrayList<>();
@Override public boolean isDisposed() {
return isDisposed.get();
}
@Override public void addListener(Listener listener) {
synchronized (listeners) {
listeners.add(listener);
}
}
@Override public void removeListener(Listener listener) {
synchronized (listeners) {
listeners.remove(listener);
}
}
@Override public void dispose() {
isDisposed.set(true);
synchronized (listeners) {
listeners.forEach(listener -> {
listener.onDisposed();
});
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy