Skip to content

Commit

Permalink
feat: add props middleware, display component and control component
Browse files Browse the repository at this point in the history
  • Loading branch information
solkimicreb committed Feb 7, 2017
1 parent bdd4ba7 commit 9178fde
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/components/control.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'

const display = require('./display')
const middlewares = require('../middlewares')

module.exports = function control (config) {
config = config || {}

return display(config)
.use(middlewares.params(config.params || {}))
}
11 changes: 11 additions & 0 deletions src/components/display.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'

const rendered = require('./rendered')
const middlewares = require('../middlewares')

module.exports = function display (config) {
config = config || {}

return rendered(config)
.use(middlewares.props.apply(null, config.props || []))
}
4 changes: 3 additions & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ module.exports = {
app: require('./app'),
page: require('./page'),
rendered: require('./rendered'),
router: require('./router')
router: require('./router'),
display: require('./display'),
control: require('./control')
}
8 changes: 3 additions & 5 deletions src/components/page.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict'

const component = require('@nx-js/core')
const rendered = require('./rendered')
const middlewares = require('../middlewares')

module.exports = function page (config) {
config = config || {}
config.params = config.params || {}

return component(config)
.use(middlewares.render(config))
return rendered(config)
.use(middlewares.meta(config))
.use(middlewares.params(config.params))
.use(middlewares.params(config.params || {}))
}
1 change: 1 addition & 0 deletions src/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module.exports = {
attributes: require('@nx-js/attributes-middleware'),
props: require('@nx-js/props-middleware'),
events: require('@nx-js/events-middleware'),
interpolate: require('@nx-js/interpolate-middleware'),
render: require('@nx-js/render-middleware'),
Expand Down

0 comments on commit 9178fde

Please sign in to comment.