[Vuejs]-Record added in nedb is single but why VUE store same record multiple times?

0👍

Each time you save a todo, you register a new listener for the IPC reply channel. The listeners all stay active and each picks and processes each event. That’s not what you want, you want to process each response only once and electron has a method for that 🙂 try this one:

    // register a listener to process the response (once)
    ipcRenderer.once('createNewTodoResponse', (e, newDoc) => {
      if (typeof newDoc === 'object') {
        this.$store.dispatch('createNewTodo', newDoc);
        $('#createNewModal').modal('hide'); 
      } else {
        $('#createNewModal').modal('hide');
      }
    });

    // send the request
    ipcRenderer.send('createNewTodo', newTodo);

Leave a comment