Skip to content

Commit

Permalink
feat(react): add combineContexts, refactor exports
Browse files Browse the repository at this point in the history
Without an exported combineContexts function, one was unable to modify the default implementation. With this commit, such modifications are being made possible.

BREAKING CHANGE: some exports have been renamed
  • Loading branch information
dmbch committed Nov 22, 2017
1 parent c54efac commit 8bd2955
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/react/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ var define = require('mixinable');

var hopsConfig = require('hops-config');

var mixin = define({
exports.combineContexts = define({
bootstrap: define.parallel,
enhanceElement: define.pipe,
getMountpoint: function (functions) {
return functions.pop()();
}
});

exports.mixin = {
exports.contextDefinition = {
constructor: function (options) {
if (!options) { options = {}; }
this.mountpoint = options.mountpoint || '#main';
Expand All @@ -35,7 +35,9 @@ exports.mixin = {
}
};

exports.createContext = mixin(exports.mixin);
exports.createContext = exports.combineContexts(
exports.contextDefinition
);

exports.render = function (reactElement, context) {
return function () {
Expand Down
8 changes: 5 additions & 3 deletions packages/react/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var hopsConfig = require('hops-config');

var defaultTemplate = require('./lib/template');

var mixin = define({
exports.combineContexts = define({
bootstrap: define.parallel,
enhanceElement: define.pipe,
getTemplateData: define.pipe,
Expand All @@ -19,7 +19,7 @@ var mixin = define({
}
});

exports.mixin = {
exports.contextDefinition = {
constructor: function () {
var args = Array.prototype.slice.call(arguments);
var options = Object.assign.apply(Object, [{}].concat(args));
Expand Down Expand Up @@ -57,7 +57,9 @@ exports.mixin = {
}
};

exports.createContext = mixin(exports.mixin);
exports.createContext = exports.combineContexts(
exports.contextDefinition
);

exports.render = function (reactElement, _context) {
return function (req, res, next) {
Expand Down

0 comments on commit 8bd2955

Please sign in to comment.