0👍
You can use subscription provided by AppSync GraphQL. It will handle DynamoDB trigger itself.
import { API, graphqlOperation } from "aws-amplify";
import { onUpdatePlayer } from "../../graphql/subscriptions";
Here’s Reactjs specific code
const PlayerComponent = () => {
let subscriptionOnUpdate;
const setupSubscriptions = () => {
subscriptionOnUpdate = API.graphql(
graphqlOperation(onUpdatePlayer)
).subscribe({
next: () => {
// do stuff like updating other state
},
})
}
useEffect(() => {
setupSubscriptions();
return () => {
subscriptionOnUpdate.unsubscribe()
}
}, [])
}
- [Vuejs]-Vuejs expression that has an or operator to check if property is found
- [Vuejs]-Javascript const object syntax – what is this doing? (using in a Vue script)
Source:stackexchange.com