public synchronized void resolve(T value) { if (state == State.FULFILLED) throw new PromiseException("Cannot resolve more than once"); if (state == State.REJECTED) throw new PromiseException("Cannot resolve an already rejected promise"); this.value = value; this.state = State.FULFILLED; if (onFulfilled != null) onFulfilled.invoke(value); if (next != null) next.resolve(value); }
public synchronized void reject(Throwable throwable) { if (state == State.REJECTED) throw new PromiseException("Cannot reject more than once"); if (state == State.FULFILLED) throw new PromiseException("Cannot resolve an already fulfilled promise"); this.value = null; this.state = State.REJECTED; this.throwable = throwable; if (onRejected != null) onRejected.invoke(throwable); if (next != null) next.reject(throwable); }
public void stop() { if (!active) return; active = false; currentFrame = 0; endCallback.invoke(); }
@Override public void prepareRenderer(MeshRenderer meshRenderer) { rendererCallback.invoke(meshRenderer); } }
public synchronized Promise<T> whenThrown(UniCallback<Throwable> onThrown) { return then(v -> { }, onThrown); }
public Promise(BiCallback<UniCallback<T>, UniCallback<Throwable>> function) { this((self, resolve, reject) -> function.invoke(resolve, reject)); }
public void pause() { if (!active) return; active = false; pauseCallback.invoke(); }
/** * Runs a callback for each of the component in the Entity. Note that you cannot add components while iterating, you * must enclose it with {@link TaskManager#runOnUpdate(SimpleCallback)} method to add before the next iteration. * * @param callback A {@link UniCallback} that will accept a component. */ public void forEachComponent(UniCallback<Component> callback) { for (Component c : components) callback.invoke(c); }
@Override public void onDrawFrame(GL10 gl) { loopFrame.invoke(); } }
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { resized.invoke(); }