Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador Video
Commits
cd635dce
Commit
cd635dce
authored
6 years ago
by
Chris Beer
Browse files
Options
Downloads
Patches
Plain Diff
Add special memoizing logic to getLocales to keep providing the same array each call
parent
ab3457e6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/state/selectors/manifests.js
+11
-2
11 additions, 2 deletions
src/state/selectors/manifests.js
with
11 additions
and
2 deletions
src/state/selectors/manifests.js
+
11
−
2
View file @
cd635dce
import
{
createSelector
}
from
'
reselect
'
;
import
{
createSelector
,
createSelectorCreator
}
from
'
reselect
'
;
import
manifesto
,
{
LanguageMap
}
from
'
manifesto.js
'
;
import
memoize
from
'
lodash/memoize
'
;
import
ManifestoCanvas
from
'
../../lib/ManifestoCanvas
'
;
/** Get the relevant manifest information */
...
...
@@ -346,7 +347,15 @@ function getLocales(resource) {
return
Object
.
keys
(
languages
);
}
export
const
getMetadataLocales
=
createSelector
(
/** */
const
manifestHashFn
=
manifest
=>
manifest
&&
manifest
.
id
;
// this has the potential to be an annoying memory leak, because the memoize store will grow
// unbounded.
const
manifestMemoizingSelectorCreator
=
createSelectorCreator
(
memoize
,
manifestHashFn
);
// this is specially memoized because getLocales is creating new array instances
// every time it is called.
export
const
getMetadataLocales
=
manifestMemoizingSelectorCreator
(
[
getManifestoInstance
],
manifest
=>
getLocales
(
manifest
),
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment