Skip to content

Commit

Permalink
Documented the dynamic configuration feature for plugins (#1651)
Browse files Browse the repository at this point in the history
* Documented the dynamic configuration feature for plugins

* Fixed typo
  • Loading branch information
mbarto authored Mar 28, 2017
1 parent 0dd0fe3 commit 6deca1d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/developer-guide/plugins-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ My.jsx:

// this is a dumb component
const MyComponent = require('../components/MyComponent');
const {connect} = require('react-redux');
const {connect} = require('../utils/PluginsUtils');

// let's wire it to state and actions
const MyPlugin = connect((state) => ({
Expand Down
37 changes: 37 additions & 0 deletions docs/developer-guide/plugins-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,41 @@ or fully configured:
]
}
```

## Dynamic configuration
Configuration properties of plugins can use expressions, so that they are dynamically bound to the
application state.

An expression is anything between curly brackets ({...}) that is a javascript expression,
where the **monitored state** of the application is available as a set of variables.

To define the monitored state, you have to add a **monitorState** property in **localConfig.json**.

```js
{
...
"monitorState": [{"name": "mapType", "path": "mapType.mapType"}]
...
}
```

Where:
* **name** is the name of the variable that can be used in expressions
* **path** is a javascript object path to the state fragment to be monitored (e.g. map.present.zoom)

When you have a monitored state, you can use it in configuration properties this way:

```js
"cfg": {
...
"myProp": "{mapType === 'openlayers' ? 1 : 2}"
...
}
```

Expressions are supported in **cfg** properties and in **hideFrom** and **showIn** sections.

In addition to monitored state also the **page request parameters** are available as variables to be
used in expressions.

Look at the [plugin reference page](./api/plugins) for a list of available configuration properties.

0 comments on commit 6deca1d

Please sign in to comment.