pubnub and head.js

ぃ、小莉子 提交于 2019-12-05 18:54:16

Thank you for asking about PubNub with Head.JS usage. I will help you get started quickly. The following is an example of how to us PubNub with Head.JS. First call the head.js() function as you normally would including the PubNub JS Lib. Then call PUBNUB.init({}) function inside the head.js callback:

head.js("/jquery.js", "http://cdn.pubnub.com/pubnub-3.3.1.min.js", function() {
    // CREATE A PUBNUB  OBJECT
    var pubnub = PUBNUB.init({
        'publish_key'   : 'pub-key',
        'subscribe_key' : 'sub-key',
        'ssl'           : false
    });
    pubnub.ready();
    pubnub.subscribe({
        channel : 'abc',
        callback : function(message) { alert(message) }
    });
});

That's it! Pretty simple right? With this code you will be able to use the PubNub Script with Head.JS easily. If there is anything that may be missing from this, please let me know and I will update the code and description.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!