priority by updating data automatically without the need of refreshing the page: - Live feeds - Counters - Push notifications Reporting dashboards are an example of these use cases.
Events. It opens a persistent connection to an HTTP Server. Those events are in the text/event-stream format. 1 var feed = new EventSource("/feed") 2 feed.onmessage = function(event) { 3 console.log(event.data) 4 }
When it receives multiple consecutive lines, it concatenates in the same event object. data: {“event”: “score”, score: [0, 1], “teams”: [FCP, SLB]} data: {“event”: “score”, score: [1, 1], “teams”: [FCP, SLB]} data: this is a multiline data: message what will be concatenated
an URL and no Headers so you can use a token as Query Parameter. The Token can be a JWT. 1 var feed = new EventSource("/feed?token=jr7g2f762f52f") 2 feed.onmessage = function(event) { 3 console.log(event.data) 4 }