1.0.2 • Published 7 years ago
cloudswept-comm v1.0.2
@cloudswept/comm
Basic JavaScript communicator implementation for SQS
create
Parameters
options
-object
- Options to create a communicator withoptions.credentialsUrl
-string
- The url to invoke to retrieve AWS credentials & contextoptions.publishUrl
-string
- The url to invoke to publishoptions.subscribeUrl
-string
- The url to invoke to subscribe to a specific topicoptions.getHeaders
-Function
- A function which provides headers while invoking requestsoptions.authenticationEmitter
-Emitter
- An emitter which should emit anauthenticated
event when authenticated, and aunauthenticated
event when unauthenticated, this will stop & start listening
Returns
Communicator
- Described below
Communicator
listen
Parameters
topic
-string
- The topic to listen toonMessage
-Function
- The function to invoke when there is anonError
-Function
- The function to invoke when an error has occurred (Optional)onCancel
-Function
- The function to invoke when the subscription is completed being cancelled (Optional)
Returns
Promise.<Function>
- A promise resolving in a function which can be invoked to cancel listening
listenWithEmitter
Parameters
topic
-string
- The topic to listen to
Returns
Promise.<ListenerEmitter>
- A promise resolving in an emitter with an additionalcancel
function which can be invoked to cancel the listener
publish
Parameters
topic
-string
- The topic to publish topayload
-string
- The payload to publish to
Returns
Promise
- A promise which resolves once the message has been published
1.0.2
7 years ago