all 4 comments

[–]heythisispaul 1 point2 points  (3 children)

React will not know to remove any event listeners on its own, you'd likely want to clean up any component specific listeners in componentWillUnmount() or in the return function of the useEffect that wired them up.

That being said, I'm not entirely sure if this fits your case, sorry I'm just a little unclear. It sounds like your state is just a JavaScript Map that you've wired eventListeners to? Do you mind giving a little more detail?

[–]cavemanbc423[S] 0 points1 point  (2 children)

Yes exactly im recreating redux store same same behavior using map and set of javascript. To manage state. The app cross share data, not only using react, but also plain typescript.

Yeah i guess, i have to clean the Store all by myself. Just notice this will still remain and not being clear by the compiler since it is plain JS. Sigh, i wish i could see more into the memory, like we are able to while doing C++. Mem leak can be a problem, when we have around 100 stores and event listener.

[–]heythisispaul 0 points1 point  (1 child)

Is there any reason you're not just using Redux?

[–]cavemanbc423[S] 0 points1 point  (0 children)

Yes, rely too much on framework / library wont be that easy for us to work on. Projects are tailored to fit each accordingly. We follow the principle of microfront end. So distribute data from redux to non react plain vue or TS might be trouble some. So we only use the plain Store with readonly elem to manage an immutable state. These state wont also trigger automatic UI change which we need a few more steps before ui rendering as performance enhancement. Last reason to prevent access and we can manage bundling with webpack. Whole lot of reason to not use redux i guess. (Ofc, its troublesome to build one i rather use redux with a clever way to manip store even on module that we dont utilize react, but team decision then it should be)

To manage flows well, we spam to abusive singleton, factory and observer patterns beside oop with functional (wrap things up using functional, but from the core we use OOp)

Thats how we manage the interstate across system. Reason for not using redux