itpresidents / thesis-archive-2020

10 stars 1 forks source link

Message hub refactor #60

Closed EonYang closed 4 years ago

EonYang commented 4 years ago

Wow, so many conflicts, lol. I tried to rebase to master locally to resolve them, but for some reason, my VS Code doesn't show my branch at all.

Here is what I did in this commit:

Refactored MessageHub, same behavior but I'm trying to not rely on creating global listeners.

I played with useContext and useReducer a little bit and had stolen some design from Redux. The result is a DIY Redux, --- obviously not as robust as Redux, but, hey I had fun making it.

There is a centralStore and dispatch stored in Context, which any component can connect to via connect function.

If you want to access it without connecting to it, just use useContext.