mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-21 11:18:12 +08:00
notes on url middleware
This commit is contained in:
@@ -15,8 +15,12 @@ const updateURLMiddleware = (store) => {
|
||||
|
||||
/************************************************************************
|
||||
*************************************************************************
|
||||
1. The state just changed. Clear, and then update, the URL.
|
||||
1a. We get the whole state tree to construct the url from
|
||||
1. Redux app state just changed. Clear URL, and then update it.
|
||||
1a. We get the whole state tree to construct the url!
|
||||
1b. But (see reducers/url.js) we try to centralize it because...
|
||||
1c. ...the back button / initial load case ('url changed' return above)
|
||||
means that we have to listen for 'url changed' and construct state
|
||||
from the browser
|
||||
*************************************************************************
|
||||
************************************************************************/
|
||||
|
||||
|
||||
+8
-4
@@ -2,17 +2,21 @@ import uri from "urijs";
|
||||
|
||||
/************************************************************************
|
||||
*************************************************************************
|
||||
# This is all of the state that will be stored in the URL query params.
|
||||
# It is reasonably important it be kept in the same place,
|
||||
1. This is all of the state that will be stored in the URL query params.
|
||||
1a. It is reasonably important it be kept in the same place,
|
||||
because if initial load or back button etc, we'll hear about that
|
||||
and manually reconstruct the state from the url, overriding whatever
|
||||
we had. We could of course listen for the "url changed" type in another
|
||||
reducer, if this gets messy.
|
||||
1b. The data structures used here are constrained as well, as urijs
|
||||
needs to be able to parse them
|
||||
*************************************************************************
|
||||
************************************************************************/
|
||||
|
||||
const url = (
|
||||
state = {},
|
||||
state = {
|
||||
selectedMetadata: {}
|
||||
},
|
||||
action
|
||||
) => {
|
||||
switch (action.type) {
|
||||
@@ -26,7 +30,7 @@ const url = (
|
||||
return state;
|
||||
}
|
||||
case "category changed": {
|
||||
/* TODO catch categories here and store a representation of them */
|
||||
|
||||
return state;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user