0

I have the following code (in index.html) that uses pubnub to receive push notification from a server:

<html>
<head>
...
</head>
<body unresolved class="fullbleed layout vertical">
<template is="dom-bind">
            <core-pubnub publish_key="xx" subscribe_key="xx">
                <core-pubnub-publish id="pub" channel="todo" message="Test"> </core-pubnub-publish>
                <core-pubnub-subscribe id="sub" channel="todo" messages="{{messages}}" presence="{{present}}" on-callback="{{subscribeCallback}}"></core-pubnub-subscribe>  
            </core-pubnub>
</template>
<script>
     var scope = document.querySelector('template[is="dom-bind"]');
     scope.subscribeCallback = function (e){
          console.log("You got something...");
     };
</script>
</body>
</html>

I am trying to know if I successfully receive a notification from the server as can be seen in the javascript code. I am not sure if this is the correct way to do it or not. Your help is appreciated here. Also, if I receive the notification, how can I read it (i.e. access {{messages}}).

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
user1894963
  • 635
  • 3
  • 11
  • 18

1 Answers1

1

Don't use {{}} for declarative event handler binding

on-callback="subscribeCallback"
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567