Skip to content

Commit

Permalink
Merge pull request #584 from A1shK/patch-3
Browse files Browse the repository at this point in the history
Update  to explicitly call out the default value for dataPath
  • Loading branch information
KetanReddy authored Feb 3, 2025
2 parents 4b4df1f + 070c014 commit 0fae159
Showing 1 changed file with 14 additions and 3 deletions.
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

0 comments on commit 0fae159

Please sign in to comment.