diff --git a/website/docs/advanced/BrownfieldIntegration.md b/website/docs/advanced/BrownfieldIntegration.md index 49707602..70de2537 100644 --- a/website/docs/advanced/BrownfieldIntegration.md +++ b/website/docs/advanced/BrownfieldIntegration.md @@ -189,17 +189,29 @@ void readStorageValue(Context ctx, String key) { AsyncStorageAccess asyncStorage = StorageModule.getStorageInstance(ctx); BuildersKt.launch(GlobalScope.INSTANCE, - Dispatchers.getIO(), - CoroutineStart.DEFAULT, - (scope, continuation) -> { - List keys = new ArrayList<>(); - keys.add(key); - - List entries = (List) asyncStorage.getValues(keys, (Continuation>) continuation); - doSomethingWithValues(entries); - - return Unit.INSTANCE; - }); + Dispatchers.getIO(), + CoroutineStart.DEFAULT, + (scope, continuation) -> { + List keys = new ArrayList<>(); + keys.add(key); + + Continuation> cont = new Continuation() { + @NotNull + @Override + public CoroutineContext getContext() { + return scope.getCoroutineContext(); + } + + @Override + public void resumeWith(@NotNull Object o) { + List entries = (List) o; + doSomethingWithEntries(entries); + } + }; + + asyncStorage.getValues(keys, cont); + return Unit.INSTANCE; + }); } ``` @@ -212,20 +224,26 @@ void saveStorageValue(Context ctx, String key, String value) { AsyncStorageAccess asyncStorage = StorageModule.getStorageInstance(ctx); BuildersKt.launch(GlobalScope.INSTANCE, - Dispatchers.getIO(), - CoroutineStart.DEFAULT, - (scope, continuation) -> { - - List entries = new ArrayList<>(); - Entry entry = new Entry(key, value); - entries.add(entry); - - asyncStorage.setValues(entries, continuation); - - return Unit.INSTANCE; - }); + Dispatchers.getIO(), + CoroutineStart.DEFAULT, + (scope, continuation) -> { + Continuation cont = new Continuation() { + @NotNull + @Override + public CoroutineContext getContext() { + return scope.getCoroutineContext(); + } + + @Override + public void resumeWith(@NotNull Object o) {} + }; + + List entries = new ArrayList<>(); + Entry entry = new Entry(key, value); + entries.add(entry); + asyncStorage.setValues(entries, cont); + return Unit.INSTANCE; + }); } ``` - -