Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return async function (dispatch, getState) {
const profile: Profile = getState().profile
pubsub = createProtocol('shareList', profile.sharesPubsubTopic, {
[protocol.queryShares.toString()]: handleQueryShares,
[protocol.sharesReply.toString()]: handleSharesReply,
[protocol.sharePush.toString()]: handleSharePush,
[protocol.shareAck.toString()]: handleShareAck,
})
await dispatch(pubsub.subscribe())
}
}
return async function (dispatch, getState) {
const profile: Profile = getState().profile
pubsub = createProtocol('chat', profile.chatPubsubTopic, {
[protocol.chat.toString()]: handleMessage,
[protocol.chatAck.toString()]: handleAck,
})
await dispatch(pubsub.subscribe())
}
}
return async function (dispatch, getState) {
const profile: Profile = getState().profile
pubsub = createProtocol('contactList', profile.contactsPubsubTopic, {
[protocol.queryContacts.toString()]: handleQueryContacts,
[protocol.contactsReply.toString()]: handleContactsReply,
[protocol.ping.toString()]: handlePing,
[protocol.pong.toString()]: handlePong,
[protocol.addedContactQuery.toString()]: handleAddedContactQuery,
[protocol.addedContactAck.toString()]: handleAddedContactAck,
})
await dispatch(pubsub.subscribe())
}
}
return async function (dispatch, getState) {
const profile: Profile = getState().profile
queryPubsub = createProtocol('contactDicovery', PUBSUB_TOPIC, {
[protocol.lookup.toString()]: handleLookup,
})
replyPubsub = createProtocol('contactDicovery', profile.contactDiscoveryPubsubTopic, {
[protocol.lookupReply.toString()]: handleLookupReply,
})
await dispatch(queryPubsub.subscribe())
await dispatch(replyPubsub.subscribe())
}
}
return async function (dispatch, getState) {
const profile: Profile = getState().profile
queryPubsub = createProtocol('contactDicovery', PUBSUB_TOPIC, {
[protocol.lookup.toString()]: handleLookup,
})
replyPubsub = createProtocol('contactDicovery', profile.contactDiscoveryPubsubTopic, {
[protocol.lookupReply.toString()]: handleLookupReply,
})
await dispatch(queryPubsub.subscribe())
await dispatch(replyPubsub.subscribe())
}
}