Invoke the Publish or Subscribe API on the Context

Publish is used to initiate an operation as shown in the following example:

<context>.publish (requestObject)

Subscribe is used to register a callback for an event from Service Center. It's like an event listener. When the event is generated in the Service Center, a corresponding callback, if registered, will be called in the UEF. SubscribeOnce is similar to subscribe. The difference is once the event is generated in the Service Center, the registered call back will be called by UEF, and it then disposes of the subscription. Here's an example:

Subscribe to an Event Subscribe Once to an Event
<context>.subscribe(requestObject, function 
callback(response){
        console.log(response)
})
<context>.subscribeOnce(requestObject,
 function callback(response){
        console.log(response)
})

Subscribe and SubscribeOnce returns a subscription object that must be deleted if the subscription is no longer in need, or else it will stay in the UEF as a garbage yet active subscription