Abdo Amin
1 min readFeb 15, 2023


Hey Laurent, the article is fascinating.

However, I was unable to understand the code flow. I'd like you to help me understand the topic more.

Here are some of my comments:

1 - in the UserService class, you are initiating the observable with an "un-invoked" subscribe function.

Thus, when a component (observer) subscribes to the service, it should pass an object (which must have a `next` method) and this object will be processed through the subscribe function...Correct?

2- In the hook useEffect, you are not passing an object, but instead a callback...Based on my previous assumption, it should be an object with a next method.

3- What does `next` do?

4- `const shouldUpdate = !this.observers.length;`

May assume the (!) is a mistake?

I think 90% of my misunderstanding is caused by not understanding how you are initiating a new observable and the `next` method.

Can you share the source code for the Observable class?

Thanks :)



Abdo Amin

I love React and anything that has JavaScript and frontend in it.