Azure-Samples / azure-cosmos-java-sql-api-samples

Sample code for Azure Cosmos DB Java SDK for SQL API
MIT License
38 stars 70 forks source link

add async samples #50

Closed TheovanKraay closed 2 years ago

kushagraThapar commented 2 years ago

This particular API is a good example of async calls ->

https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/main/src/main/java/com/azure/cosmos/examples/crudquickstart/async/SampleCRUDQuickstartAsync.java#L222 Notice how it uses subscribe() instead of block() which is used everywhere else.

For async samples, we should use subscribe() API to subscribe to async API and let them run in background. The samples should reflect this pattern. Otherwise customers will copy paste the blocking calls and doesn't work well in all scenarios.