docs icon indicating copy to clipboard operation
docs copied to clipboard

Android DataStore invalid code snippets

Open lawmicha opened this issue 3 years ago • 0 comments

Describe the bug Android DataStore code snippets do not compile

To Reproduce 1a. See https://docs.amplify.aws/lib/datastore/data-access/q/platform/android/#predicates

Under "Kotlin - Callbacks"

Amplify.DataStore.query(Post::class.java,
    { posts ->
        while (posts.hasNext()) {
            val post = allPosts.next()
            Log.i("MyAmplifyApp", "Title: ${post.title}")
        }
    },
    { Log.e("MyAmplifyApp", "Query failed", it) }
)

It appears allPosts should be posts.

1b. Under Delete image

Remove first sentence. This might require some work due to shared fragments

2a. See https://docs.amplify.aws/lib/datastore/real-time/q/platform/android/

Amplify.DataStore.observe(Post::class.java,
    { Log.i("MyAmplifyApp", "Observation began") },
    {
        val post = postChanged.item()
        Log.i("MyAmplifyApp", "Post: $post")
    },
    { Log.e("MyAmplifyApp", "Observation failed", it) },
    { Log.i("MyAmplifyApp", "Observation complete") }
)

"postChanged" should be "it" i think, here's a screenshot of the code in Android Studio image

2b. Indentation on the RT page looks off image

lawmicha avatar Jul 26 '22 15:07 lawmicha