You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's first add a button to create a new todo item. To make a "create Todo" API request, generate the data client using `generateClient()` in your frontend code, and then call `.create()` operation for the Todo model. The Data client is a fully typed client that gives you in-IDE code completion. To enable this in-IDE code completion capability, pass in the `Schema` type to the `generateClient` function.
366
366
@@ -391,8 +391,44 @@ Run the application in local development mode and check your network tab after c
391
391
Try playing around with the code completion of `.update(...)` and `.delete(...)` to get a sense of other mutation operations.
392
392
393
393
</Callout>
394
+
</InlineFilter>
395
+
396
+
<InlineFilterfilters={["angular"]}>
397
+
398
+
Let's first add a button to create a new todo item. To make a "create Todo" API request, generate the data client using `generateClient()` in your frontend code, and then call `.create()` operation for the Todo model. The Data client is a fully typed client that gives you in-IDE code completion. To enable this in-IDE code completion capability, pass in the `Schema` type to the `generateClient` function.
<button (click)="createTodo()">Add new todo</button>
411
+
`
412
+
})
413
+
exportclassTodoListComponent {
414
+
async createTodo() {
415
+
awaitclient.models.Todo.create({
416
+
content: window.prompt("Todo content?"),
417
+
isDone: false
418
+
});
419
+
}
420
+
}
421
+
```
422
+
423
+
Run the application in local development mode and check your network tab after creating a todo. You should see a successful request to a `/graphql` endpoint.
424
+
425
+
<Callout>
426
+
427
+
Try playing around with the code completion of `.update(...)` and `.delete(...)` to get a sense of other mutation operations.
394
428
429
+
</Callout>
395
430
</InlineFilter>
431
+
396
432
<InlineFilterfilters={["android"]}>
397
433
398
434
In your MainActivity, add a button to create a new todo.
@@ -583,9 +619,7 @@ Creating Todo successful.
583
619
584
620
Next, list all your todos and then refetch the todos after a todo has been added:
Now try to open your app in two browser windows and see how creating a todo in one window automatically adds the todo in the second window as well.
1048
+
1049
+
<Callout>
1050
+
1051
+
You can also use `.onCreate`, `.onUpdate`, or `.onDelete` to subscribe to specific events. Review [Subscribe to real-time events](/[platform]/build-a-backend/data/subscribe-data) to learn more about subscribing to specific mutation events.
1052
+
1053
+
</Callout>
1054
+
1055
+
</InlineFilter>
1056
+
896
1057
<InlineFilterfilters={["android"]}>
897
1058
898
1059
To add real-time updates, you can use the subscription feature of Amplify Data. It allows to subscribe to `onCreate`, `onUpdate`, and `onDelete` events of the application. In our example, let's append the list every time a new todo is added.
0 commit comments