https://github.com/idyll-lang/idyll-context-compose
Compose multiple contexts; makes it easier to work with multiple runtime plugins.
https://github.com/idyll-lang/idyll-context-compose
Last synced: 29 days ago
JSON representation
Compose multiple contexts; makes it easier to work with multiple runtime plugins.
- Host: GitHub
- URL: https://github.com/idyll-lang/idyll-context-compose
- Owner: idyll-lang
- License: mit
- Created: 2018-11-20T22:03:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-22T04:40:52.000Z (over 6 years ago)
- Last Synced: 2025-04-09T23:26:29.440Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# idyll-context-compose
Compose multiple contexts; makes it easier to work with multiple [Idyll runtime plugins](https://github.com/idyll-lang/idyll-plugins).
## Example
Say you want to use a runtime plugin like [url-state](idyll-plugin-url-state) but also add your own custom context processing code:
*context.js*
```js
const URLState = require('idyll-plugin-url-state');
const compose = require('idyll-context-compose');const customContext = (ctx) => {
// To listen for changes:
ctx.onUpdate((newData) => {
console.log('[custom context]', newData);
})
}module.exports = compose(URLState, customContext);
```## Installation
```
$ npm install --save -context-compose
```### Adding a custom context file
To use this library, you'll need to tell Idyll to use a custom context. To do that, create a `context.js` file, and point Idyll to in in `package.json`:
```
"idyll": {
"context": "./context.js"
}
```