@smartface/contx
Advanced tools
Comparing version 1.0.0-rc.16 to 1.0.0-rc.17
@@ -59,3 +59,3 @@ (function (global, factory) { | ||
_this._dispatcher = dispatcher; | ||
_this._actorInternal_.component.setContextDispatcher ? _this._actorInternal_.component.setContextDispatcher(function (action) { | ||
_this._actorInternal_.component.didComponentEnter ? _this._actorInternal_.component.didComponentEnter(function (action) { | ||
dispatcher(action, _this.getName()); | ||
@@ -62,0 +62,0 @@ }) : _this._actorInternal_.component.dispatch = function (action) { |
@@ -156,3 +156,3 @@ (function (global, factory) { | ||
e.message = "An Error is occurred When action [" + action.type + "] run on target [" + target + "]. " + e.message; | ||
(0, _raiseErrorMaybe2.default)(e, _this.actors.collection[target].onError); | ||
(0, _raiseErrorMaybe2.default)(e, target && _this.actors.collection[target].onError); | ||
} | ||
@@ -159,0 +159,0 @@ }; |
@@ -45,8 +45,2 @@ (function (global, factory) { | ||
page.themeContext = Application.theme((0, _pageContext2.default)(page, name, null, null), name); | ||
// page.themeContext({ | ||
// type: "addThemeableContext", | ||
// name: name, | ||
// pageContext: | ||
// }); | ||
} | ||
@@ -60,5 +54,2 @@ | ||
superOnShow && superOnShow(data); | ||
// this.dispatch && this.dispatch({ | ||
// type: "onShowUpdate" | ||
// }); | ||
@@ -65,0 +56,0 @@ this.dispatch && this.dispatch({ |
@@ -134,7 +134,4 @@ (function (global, factory) { | ||
// this.styles === userStyle && (diff = merge(diff, userStyle)); | ||
var beforeHook = _this.hook("beforeStyleDiffAssign"); | ||
var diff = beforeHook && beforeHook(rawDiff) || null; | ||
var comp = name.indexOf("_") === -1 && _this._actorInternal_.component.layout ? _this._actorInternal_.component.layout : _this._actorInternal_.component; | ||
@@ -141,0 +138,0 @@ var hasDiff = Object.keys(diff).length > 0; |
@@ -83,8 +83,24 @@ (function (global, factory) { | ||
function Theme(_ref) { | ||
var _this = this; | ||
var name = _ref.name, | ||
rawStyles = _ref.rawStyles, | ||
isDefault = _ref.isDefault; | ||
_ref$isDefault = _ref.isDefault, | ||
isDefault = _ref$isDefault === undefined ? false : _ref$isDefault; | ||
_classCallCheck(this, Theme); | ||
this.isDefault = function () { | ||
return _this._isDefault; | ||
}; | ||
this.setDefault = function (value) { | ||
_this._isDefault = value; | ||
value && !_this.bundle && _this.build(); | ||
}; | ||
this.build = function () { | ||
_this.bundle = (0, _buildStyles2.default)(_this.rawStyles); | ||
}; | ||
this.name = name; | ||
@@ -95,13 +111,2 @@ this.rawStyles = rawStyles; | ||
Theme.prototype.setDefault = function setDefault(value) { | ||
this.isDefault = value; | ||
value && this.build(); | ||
}; | ||
Theme.prototype.build = function build() { | ||
if (!this.bundle) { | ||
this.bundle = (0, _buildStyles2.default)(this.rawStyles); | ||
} | ||
}; | ||
Theme.prototype.asStyler = function asStyler() { | ||
@@ -120,16 +125,10 @@ return (0, _styler2.default)(this.bundle); | ||
var _this = _possibleConstructorReturn(this, _Actor.call(this, pageContext)); | ||
var _this2 = _possibleConstructorReturn(this, _Actor.call(this, pageContext)); | ||
_this.whenContextChanged = function (state, oldState) { | ||
if (state.theme !== oldState.theme) { | ||
_this.pageContext(state.theme.asStyler()); | ||
} | ||
}; | ||
_this.pageContext = pageContext; | ||
return _this; | ||
_this2.pageContext = pageContext; | ||
return _this2; | ||
} | ||
Themeable.prototype.changeTheme = function changeTheme(theme) { | ||
this.pageContext(theme.asStyler()); | ||
Themeable.prototype.changeStyling = function changeStyling(styling) { | ||
this.pageContext(styling); | ||
this.isDirty = true; | ||
@@ -155,4 +154,2 @@ }; | ||
function themesReducer(context, action, target) { | ||
var _context$setActors; | ||
var state = context.getState(), | ||
@@ -162,13 +159,19 @@ newState = state; | ||
switch (action.type) { | ||
case 'addThemeableContext': | ||
case 'addThemeable': | ||
// make declarative | ||
context.setActors((_context$setActors = {}, _context$setActors[action.name] = new Themeable(action.pageContext), _context$setActors)); | ||
context.map(function (actor) { | ||
state.theme instanceof Theme && actor.changeTheme(state.theme); | ||
context.add(new Themeable(action.pageContext), action.name); | ||
themesCollection.forEach(function (theme) { | ||
return theme.isDefault() && context.map(function (actor) { | ||
actor.changeStyling(theme.asStyler()); | ||
}); | ||
}); | ||
break; | ||
case 'removeThemeable': | ||
context.remove(action.name); | ||
break; | ||
case 'changeTheme': | ||
context.map(function (actor) { | ||
state.theme instanceof Theme && actor.changeTheme(action.theme); | ||
themesCollection.forEach(function (theme) { | ||
return theme.name === action.theme && theme.setDefault(true) && context.map(function (actor) { | ||
actor.changeStyling(theme.asStyler()); | ||
}) || theme.setDefault(false); | ||
}); | ||
@@ -208,4 +211,4 @@ | ||
themeContext.dispatch({ | ||
type: "addThemeableContext", | ||
pageContext === null ? themeContext.dispose() : pageContext !== undefined && themeContext.dispatch({ | ||
type: "addThemeable", | ||
name: name, | ||
@@ -216,8 +219,8 @@ pageContext: pageContext | ||
return function themeContextDispatch(action) { | ||
var dispose = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
if (action === null) { | ||
pageContext.dispose(); | ||
dispose && themeContext.dispose(); | ||
} else if (context) { | ||
name && themeContext.dispatch({ | ||
type: "removeThemeable", | ||
name: name | ||
}); | ||
} else { | ||
themeContext.dispatch(action); | ||
@@ -224,0 +227,0 @@ } |
{ | ||
"name": "@smartface/contx", | ||
"version": "1.0.0-rc.16", | ||
"version": "1.0.0-rc.17", | ||
"description": "Context Manager", | ||
@@ -5,0 +5,0 @@ "scripts": { |
81062
1830