Arquisoft / dashboard_i3b

The Unlicense
0 stars 1 forks source link

Send model and data in emitters as attributes of the model #2

Closed juanfadev closed 7 years ago

juanfadev commented 7 years ago

proposals variable is updated from database whenever an update comes it then sends data as raw text toString() to the browser using a foreach of proposals

@RequestMapping(path = "/", method = RequestMethod.POST)
    @KafkaListener(topics = "updates")
    public String showMessage(String data) {
        proposals = service.getAllProposal();
        synchronized (this.sseEmitters) {
            for (SseEmitter sseEmitter : this.sseEmitters) {

                proposals.parallelStream().forEach(c -> {
                    try {
                        sseEmitter.send(c.toString());
                    } catch (Exception e) {
                        logger.error("Se ha cerrado el navegador");
                    }
                });

            }
        }
        //creo que aqui se puede mandar un modelo y data como un atributo del modelo igual que la anterior vez
        return data;
    }

We sould need to send model to the view and send the emitter data as an attribute of the model, not the data itself as raw text

juanfadev commented 7 years ago

@guille I've just changed this. If you check index.html you can see how it gets events from different urls, and parse them as an element in the dom using EventSource in Githubissues.

  • Githubissues is a development platform for aggregating issues.