-
Notifications
You must be signed in to change notification settings - Fork 9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(json-schema-2020-12-sample): introduce option API (#9795)
Refs #9739
- Loading branch information
Showing
4 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/core/plugins/json-schema-2020-12-samples/fn/api/optionAPI.js
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,17 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
|
||
import OptionRegistry from "../class/OptionRegistry" | ||
|
||
const registry = new OptionRegistry() | ||
|
||
const optionAPI = (optionName, optionValue) => { | ||
if (typeof optionValue !== "undefined") { | ||
registry.register(optionName, optionValue) | ||
} | ||
|
||
return registry.get(optionName) | ||
} | ||
|
||
export default optionAPI |
16 changes: 16 additions & 0 deletions
16
src/core/plugins/json-schema-2020-12-samples/fn/class/OptionRegistry.js
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,16 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
import Registry from "./Registry" | ||
|
||
class OptionRegistry extends Registry { | ||
#defaults = {} | ||
|
||
data = { ...this.#defaults } | ||
|
||
get defaults() { | ||
return { ...this.#defaults } | ||
} | ||
} | ||
|
||
export default OptionRegistry |
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