问题描述
我有一个待办事项列表,当从列表中添加或删除项目时,我希望收到通知.
I have a list of todo items and I would like to receive notifications when items are added or deleted from the list.
到目前为止,我已经实施了商品添加通知:
So far I have implemented item addition notification:
<Connect
query={graphqlOperation(listTodos)}
subscription={graphqlOperation(onCreateTodo)}
onSubscriptionMsg={(prev, { onCreateTodo }) => {
return addItem(prev, onCreateTodo)
}}
>
{({ data: { listTodos }, loading, error }) => {
if (loading) return "Loading"
if (error) return "Error"
return listTodos.items
.map(({ id, name }) => <div key={id}>{name}</div>)
}}
</Connect>
现在我想知道如何向该组件添加项目删除通知?订阅属性是否接受一个graphql操作数组?
Now I am wondering, how can I add item deletion notification to this component? Does subscription attribute accept an array of graphql operations?
谢谢!
推荐答案
看起来像当前解决方案是创建自己的Connect组件实现,如此github问题中所述: https://github.com/aws-amplify/amplify-js/issues/4813#issuecomment-582106596
Looks like the current solution is to create your own implementation of the Connect component as described in this github issue: https://github.com/aws-amplify/amplify-js/issues/4813#issuecomment-582106596
这篇关于AWS Amplify react Connect组件中的多个订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!