Skip to content

Instantly share code, notes, and snippets.

@mindwing
Created June 8, 2016 05:24
Show Gist options
  • Save mindwing/742fddb636a6b6973192073f49edc784 to your computer and use it in GitHub Desktop.
Save mindwing/742fddb636a6b6973192073f49edc784 to your computer and use it in GitHub Desktop.
Agera Explained - 08.Incrementally Agerifying legacy code
public class NetworkCallingSupplier implements Supplier<Result<ResponseBlob>> {
private final RequestBlob request = …;
@Override
public Result<ResponseBlob> get() {
try {
ResponseBlob blob = networkStack.execute(request); // blocking call
return Result.success(blob);
} catch (Throwable e) {
return Result.failure(e);
}
}
}
Supplier<Result<ResponseBlob>> networkCall = new NetworkCallingSupplier();
Repository<Result<ResponseBlob>> responseRepository =
Repositories.repositoryWithInitialValue(Result.<ResponseBlob>absent())
.observe() // no event source; works on activation
.onUpdatesPerLoop() // but this line is still needed to compile
.goTo(networkingExecutor)
.thenGetFrom(networkCall)
.compile();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment