|
|
|
|
|
by adamkl
2327 days ago
|
|
This sounds very similar to what we've been doing with XState[1] and React. We have a "service layer" for React made up of state-machine-based services (although reactive services based on RxJS observables works as well). We also created associated custom hooks that allow developers to easily "inject" a service into their React component (use use React's Context API for our "DI container"). From there they can read the service state, or send events to it to trigger behaviour that is encapsulated in the service itself. We even have the same "most used" service; a UserSession service manages OAuth based login flow and session management. The best part of this approach is that our service layer started in an Angular based proof-of-concept before we lifted-and-shifted it all into React. [1] https://xstate.js.org/ |
|