Created
June 8, 2016 05:24
-
-
Save mindwing/742fddb636a6b6973192073f49edc784 to your computer and use it in GitHub Desktop.
Agera Explained - 08.Incrementally Agerifying legacy code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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