How to use the event-source-polyfill.EventSourcePolyfill function in event-source-polyfill

To help you get started, we’ve selected a few event-source-polyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github latenighttales / alcali / src / components / core / Layout.vue View on Github external
saltStatus() {
        // Various Salt event tag matchers.
        let isJobEvent = helpersMixin.methods.fnmatch("salt/job/*")
        let isJobNew = helpersMixin.methods.fnmatch("salt/job/*/new")
        let isJobReturn = helpersMixin.methods.fnmatch("salt/job/*/ret/*")
        const accessToken = localStorage.getItem("access")
        let es = new EventSourcePolyfill("/api/event_stream/", {
          headers: {
            "Authorization": `Bearer ${accessToken}`,
          },
        })
        es.addEventListener("open", () => {
          this.$store.dispatch("updateWs")

        })
        es.addEventListener("message", event => {
          let data = JSON.parse(event.data)
          // Display only activated notifs.
          if (isJobNew(data.tag) && this.notifs.published === true) {
            if (data.data.fun !== 'saltutil.find_job') {
              data.type = "new"
              data.color = "green"
              data.icon = "keyboard_tab"
github bosch-io / iot-things-examples / octopus-bidirectional / iot-frontend / src / utils / bus.js View on Github external
fire(event, data = null) {

        if (event === "initSSE") {

            // start listening with a little timeout
            let values = Object.values(this.vue.items);
            let thingIds = values.map(element => element.thingId).join(",");
            switch(this.vue.suiteAuthActive){
                case true:
                    this.source = new EventSourcePolyfill(
                        `${
                            this.vue.connection.http_endpoint
                            }/api/2/things?ids=${thingIds}&fields=thingId,policyId,attributes,features,_revision`,
                        {
                            headers: {
                                Authorization: Api.getConfig().headers.Authorization
                            },
                            withCredentials: true
                        }
                    );
                break;
                case false:
                    this.source = new EventSourcePolyfill(
                        `${
                            this.vue.connection.http_endpoint
                            }/api/2/things?ids=${thingIds}&x-cr-api-token=${

event-source-polyfill

A polyfill for http://www.w3.org/TR/eventsource/

MIT
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis