forked from inveniosoftware/react-invenio-forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Singleton class meant to manage the global overriden components * closes inveniosoftware/invenio-app-rdm#2018
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// This file is part of React-Invenio-Forms | ||
// Copyright (C) 2023 CERN. | ||
// | ||
// React-Invenio-Forms is free software; you can redistribute it and/or modify it | ||
// under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
let components; | ||
|
||
/** | ||
* Singleton class to provide a global access point to the overriden components | ||
*/ | ||
class OverridenSingleton { | ||
constructor() { | ||
if (!OverridenSingleton.instance) { | ||
OverridenSingleton.instance = this; | ||
} | ||
|
||
return OverridenSingleton.instance; | ||
} | ||
|
||
getComponents() { | ||
return components; | ||
} | ||
|
||
addComponents(newComponents) { | ||
components = { ...components, ...newComponents }; | ||
} | ||
} | ||
|
||
export const overridableRegistry = new OverridenSingleton(); |