terriajs
terriajs copied to clipboard
Apply all `InitSources` sequentially instead of asynchronously
Apply all InitSources
sequentially instead of asynchronously
Fixes #5949
InitSources
should be applied on top of each other - in order specified by terria.initSources
array.
I have added an init-sources
doc - https://github.com/TerriaJS/terriajs/blob/abac123141f60541fb5b383e60355c2f26ec7a5b/doc/contributing/init-sources.md
For example - these should be applied in order
-
config.initializationUrls
- these are added in
terria.start() -> terria.setupInitializationUrls()
- these are added in
-
updateApplicatonUrl
-
interpretHash
- init fragments - eg
#simple
or#https://some.url/config.json
-
#start
-
#share
- init fragments - eg
-
/catalog/
routes -
/story/
routes
-
When InitSources
are applied (see terria.applyInitData()
) there are two async tasks
-
loadModelStratum
- Loading models and adding them to the workbench
Depending on these tasks, InitSources
may be applied out of order, at random times - and may get interlaced
This PR makes sure InitSources
are applied in order
Test me
The following URL has
-
configUrl
- https://gist.githubusercontent.com/nf-s/167f4749a4911288c54641589f417ecd/raw/55fd4f27c28dfe4636e119d84b2b1503117624a7/geo-rapp-fragment-path.json
- This add the following
initializationUrl
- https://terria-catalogs-public.storage.googleapis.com/geo-rapp/dev.json
- Which set
workbench: ["tN2nrg", "LfaYaM", "idvaI5"]
- Which set
- https://terria-catalogs-public.storage.googleapis.com/geo-rapp/dev.json
- Init fragment https://terria-catalogs-public.storage.googleapis.com/geo-rapp/dev/australia.json
- Which should override
workbench: ["nrm-regions-2017"]
- Which should override
Before - http://ci.terria.io/main/#configUrl=https://gist.githubusercontent.com/nf-s/167f4749a4911288c54641589f417ecd/raw/55fd4f27c28dfe4636e119d84b2b1503117624a7/geo-rapp-fragment-path.json&https://terria-catalogs-public.storage.googleapis.com/geo-rapp/dev/australia.json
After - http://ci.terria.io/sync-init-source/#configUrl=https://gist.githubusercontent.com/nf-s/167f4749a4911288c54641589f417ecd/raw/55fd4f27c28dfe4636e119d84b2b1503117624a7/geo-rapp-fragment-path.json&https://terria-catalogs-public.storage.googleapis.com/geo-rapp/dev/australia.json
Checklist
- [x] There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)
- [x] I've updated relevant documentation in
doc/
. - [x] I've updated CHANGES.md with what I changed.
- [x] I've provided instructions in the PR description on how to test this PR.