lib/services/StyleContext.js
function createStyleContext(actors, hooks) {
    var context;

    /**
     * Composes a context.
     * 
     * @param {function) styling - Styling function from styler.
     * @param {function} reducer - Reducer function to run actions
     */
    return function composeContext(styling, reducer) {
      var latestState = context ? context.getState() : {};
      context && context.dispose();

      context = (0, _Context2.default)(actors, function contextUpdater(context, action, target) {
        var state = context.getState(),
            newState = state;

        if (target || action.type == _Context.INIT_CONTEXT_ACTION_TYPE) {
          newState = reducer(state, context.actors, action, target);
          // state is not changed
          if (newState === state) {
            // return current state instance
            return state;
          }
        }

        Object.keys(context.actors).forEach(function setInitialStyles(name) {
          var comp = context.actors[name];

          if (comp.isUgly === true || action.type === _Context.INIT_CONTEXT_ACTION_TYPE) {

            var className = context.actors[name].getClassName();
            var beforeHook = hooks("beforeAssignComponentStyles");
            beforeHook && (className = beforeHook(name, className));

            var styles = styling(className + " #" + name)();
            context.actors[name].setStyles(styles);
            comp.isUgly = false;
          }
        });

        latestState = newState;

        return newState;
      }, latestState);

      Object.keys(context.actors).forEach(function assignContext(name) {
        context.actors[name].isUgly = true;
        context.actors[name].setContext(context);
      });

      return context;
    };
  }
function createStyleContext(actors, hooks) {
    var context;

    /**
     * Composes a context.
     * 
     * @param {function) styling - Styling function from styler.
     * @param {function} reducer - Reducer function to run actions
     */
    return function composeContext(styling, reducer) {
      var latestState = context ? context.getState() : {};
      context && context.dispose();

      context = (0, _Context2.default)(actors, function contextUpdater(context, action, target) {
        var state = context.getState(),
            newState = state;

        if (target || action.type == _Context.INIT_CONTEXT_ACTION_TYPE) {
          newState = reducer(state, context.actors, action, target);
          // state is not changed
          if (newState === state) {
            // return current state instance
            return state;
          }
        }

        Object.keys(context.actors).forEach(function setInitialStyles(name) {
          var comp = context.actors[name];

          if (comp.isUgly === true || action.type === _Context.INIT_CONTEXT_ACTION_TYPE) {

            var className = context.actors[name].getClassName();
            var beforeHook = hooks("beforeAssignComponentStyles");
            beforeHook && (className = beforeHook(name, className));

            var styles = styling(className + " #" + name)();
            context.actors[name].setStyles(styles);
            comp.isUgly = false;
          }
        });

        latestState = newState;

        return newState;
      }, latestState);

      Object.keys(context.actors).forEach(function assignContext(name) {
        context.actors[name].isUgly = true;
        context.actors[name].setContext(context);
      });

      return context;
    };
  }
function createStyleContext ( actors , hooks ) { var context ; /**
     * Composes a context.
     * 
     * @param {function) styling - Styling function from styler.
     * @param {function} reducer - Reducer function to run actions
     */ return function composeContext ( styling , reducer ) { var latestState = context ? context . getState ( ) : { } ; context && context . dispose ( ) ; context = ( 0 , _Context2 . default ) ( actors , function contextUpdater ( context , action , target ) { var state = context . getState ( ) , newState = state ; if ( target || action . type == _Context . INIT_CONTEXT_ACTION_TYPE ) { newState = reducer ( state , context . actors , action , target ) ; // state is not changed if ( newState === state ) { // return current state instance return state ; } } Object . keys ( context . actors ) . forEach ( function setInitialStyles ( name ) { var comp = context . actors [ name ] ; if ( comp . isUgly === true || action . type === _Context . INIT_CONTEXT_ACTION_TYPE ) { var className = context . actors [ name ] . getClassName ( ) ; var beforeHook = hooks ( "beforeAssignComponentStyles" ) ; beforeHook && ( className = beforeHook ( name , className ) ) ; var styles = styling ( className + " #" + name ) ( ) ; context . actors [ name ] . setStyles ( styles ) ; comp . isUgly = false ; } } ) ; latestState = newState ; return newState ; } , latestState ) ; Object . keys ( context . actors ) . forEach ( function assignContext ( name ) { context . actors [ name ] . isUgly = true ; context . actors [ name ] . setContext ( context ) ; } ) ; return context ; } ; }
Style Context. Returns context composer

@param {Array.<Object>} actors - Actors List
@param {function} hooks - Hooks callback
@returns {function} - Context Composer Function
Style Context . Returns context composer