all files / style/ StyleFactory.js

100% Statements 9/9
100% Branches 0/0
100% Functions 3/3
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                                                               
/**
 * @author syt123450 / https://github.com/syt123450
 */
 
/**
 * The StyleFactory will persist all pre-defined style, and return style object to ConfigureHandler by a given name
 */
 
var StyleFactory = ( function () {
 
    var styleMap = {};
 
    // get style API for ConfigureHandler to get a specific style object by name
 
    function getStyle ( styleName ) {
 
        return styleMap[ styleName ];
 
    }
 
    //register API for style creator
 
    function register( styleName, style ) {
 
        styleMap[ styleName ] = style;
 
    }
 
    return {
 
        getStyle: getStyle,
 
        register: register
 
    }
 
}() );
 
export { StyleFactory }