#29 fix race condition related to retrieving organizations
Closes #29 (closed)
If you read over #29 (closed), you'll see that the primary goal was to make sure that retrieveOrganizations
didn't happen until the RoutesRecognized
event in the Router lifecycle happened. In addition, I need a safeguard to ensure that retrieveOrganizations
doesn't happen more than once. RoutesRecognized
will fire when you change pages, but as of today we don't need to re-query the organizations API when that happens.
This MR accomplishes that. I'm not sure I did it in the right spot or in the right way, though.
- I have BehaviorSubject stuff in a component, when we usually do that in a service. How bad is that? Felt wrong to start a RouterService for two booleans.
- There is routeParams stuff in organizations.service already (although it's not in the BehaviorSubject for some reason), and we already import org service to call retrieveOrganizations. So there's a strong case to put routeParams into the org service's BehaviorSubject and import it into app component.
- However, app.component doesn't really care what routeParams are; it only cares if a certain router event fired. We already had one condition like this: isLoggedIn. Now we have three: isLoggedIn, routesRecognized, and retrieveOrgsFiredOnce. They're annotated.
Edited by Brendan Berkley