Skip to content

idyll-lang/idyll-context-compose

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

idyll-context-compose

Compose multiple contexts; makes it easier to work with multiple Idyll runtime plugins.

Example

Say you want to use a runtime plugin like url-state but also add your own custom context processing code:

context.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"
}

About

Compose multiple contexts; makes it easier to work with multiple runtime plugins.

Resources

License

Stars

Watchers

Forks

Packages

No packages published