Related updates, additions, or deletions of data online via AppSync cause any subscribers to have the given closures called. In most cases, the app wants to update its local store of that data. One route for that would be to simply update the data via a fetch. However, it may just store the new data locally.
- So now, we're going to look at subscribing…to events when new posts are created…and how to handle that in the app.…So we need to subscribe to that…and pass in a closure to be called…whenever there's a new post.…So let's go the ThoughtsTVC.swift file.…I'm going to delete all my break points…and towards the top of the class itself…we're going to create a new property.…So on line 65 I'm going to add var watcher…and specify the type as an AWSAppSync subscription watcher…and it has a generic and we'll specify…the OnCreatePostSubscription and it's an optional…We're going to create it when we subscribe.…
And I'm going to create that subscription…function all the way at the bottom.…But I want to call it up here whenever the user is signed in.…So I'm going to say on line 82, when we know…we have a signed in user, start subscription…and I'll copy that and I'm also going to call that…after the user first signs in on line 91.…So all the way at the bottom on line 322…I'm going to write function, start subscription.…And the first thing I want to do is make sure…
- Preparing to use AppSync in code
- Updating settings and the schema
- Adding a second data source
- Storing posts online
- Updating subscriptions in schema
- Testing live updates
- Handling updated posts
- Offline capabilities
Skill Level Intermediate
1. AWS User Authentication
2. AppSync Setup
Amplify codegen3m 42s
3. App Code and Configuration
4. Adding a Second Datasource
5. Real-Time Updates
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.