Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to explicitly call out the default value for dataPath #584

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const constantsPlugin = new ConstantsPlugin({
prop2: "B",
},
namespace: "constants",
dataPath: "data.constants",
dataPath: "data.props",
});

const player = new Player({
Expand All @@ -42,12 +42,12 @@ constantsPlugin.getConstants("prop1"); // 'A'

### Overriding Values in Content

The `dataPath` configuration option enables content to override specific values for a particular flow:
By default, data can be provided in the `constants` path of the `data` object to override the constants that the plugin was initialized with. This can be overridden though via the `dataPath` configuration option. In the above example, `dataPath` was initialized with the path `data.props` therefore the following code snippet could be used to override the `prop1` constant:

```json
{
"data": {
"constants": {
"props": {
"prop1": "B"
}
}
Expand All @@ -56,6 +56,17 @@ The `dataPath` configuration option enables content to override specific values

using a similar query for `prop1`, the value in the content takes precidence and would return `B`.

If no `dataPath` is defined, then it defaults to `constants` and you can still do this
```json
{
"data": {
"constants": {
"prop1": "B"
}
}
}
```

### Fallback Values

Any query can also specify an optional _default_ value to return:
Expand Down