package speiger.src.coreengine.assets.api;

import java.util.concurrent.CompletableFuture;

public abstract class SteppedResourceListener<T> implements IResourceListener {
	@Override
	public CompletableFuture<Void> reload(ReloadContext context, ISyncer sync) {
		return CompletableFuture.supplyAsync(() -> prepare(context), context.tasks()).thenCompose(sync::sync).thenAccept(T -> apply(T, context));
	}
	
	protected abstract T prepare(ReloadContext context);
	protected abstract void apply(T value, ReloadContext context);
}
