0

I'm developing this library and when I test it on Stackblitz using pure typescript it works fine. In the linked demo, if you look at the console log, there's one logging statement generated for each post to the store.

I'm also testing the same thing out in a mini Todo app with Angular, and each time the user enters a new Todo title, the console logs the number of entries in the store. In other words if there are 10 entries in the store, the array of entries will be logged 10 times, instead of just once.

I'm trying to figure out if there's something wrong with my App / library or if it's something wrong with Stackblitz ....

This is the Stackblits app: https://stackblitz.com/edit/slice-todo?file=src%2Fapp%2Fapp.component.ts

Thoughts?

Ole
  • 41,793
  • 59
  • 191
  • 359

1 Answers1

2

You are subscribing in addTodo method. Every time it just adds a new listener. You should subscribe here only once in constructor or init

Ebuall
  • 1,306
  • 1
  • 12
  • 14