Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public void run1(String endPoint) {
WsProvider wsProvider = new WsProvider(endPoint);
Promise<ApiPromise> ready = ApiPromise.create(wsProvider);
IRpcFunction.Unsubscribe<Promise> unsubscribeHandler = null;
ready.then( (ApiPromise api) -> {
Promise<IRpcFunction.Unsubscribe<Promise>> invoke = api.rpc().chain().function("subscribeNewHead").invoke(
(IRpcFunction.SubscribeCallback<Header>) (Header header) ->
System.out.println("Chain is at block: " + header.getBlockNumber()+" trigger "+count);
if (count >5) {
return invoke;
}).then((IRpcFunction.Unsubscribe<Promise> result) -> {
// Results in compile error: "Variable used in lambda expression should be final or effectively final
unsubscribeHandler =result;
return null;
})._catch((err) -> {
return Promise.value(err);
try {
} catch (InterruptedException e) {

This comment has been minimized.

Copy link
Owner Author

commented Aug 5, 2019

This results in a compile error on line 19. A local variable out-of-scope of the lambda expression must be final.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.