11import { createLogicMiddleware } from 'redux-logic' ; // peerDependency
22import { createAspect ,
3- extendAspectProperty ,
43 launchApp } from 'feature-u' ; // peerDependency:
54
65// our logger (integrated/activated via feature-u)
@@ -9,35 +8,16 @@ const logf = launchApp.diag.logf.newLogger('- ***feature-redux-logic*** logicAsp
98// NOTE: See README for complete description
109export default createAspect ( {
1110 name : 'logic' ,
12- genesis,
1311 validateFeatureContent,
1412 assembleFeatureContent,
15- createLogicMiddleware$,
1613 getReduxMiddleware,
14+ config : {
15+ allowNoLogic$ : false , // PUBLIC: client override to: true || [{logicModules}]
16+ createLogicMiddleware$, // HIDDEN: createLogicMiddleware$(app, appLogic): reduxMiddleware
17+ } ,
1718} ) ;
1819
1920
20- /**
21- * Register feature-redux-logic proprietary Aspect APIs (required to
22- * pass feature-u validation).
23- * This must occur early in the life-cycle (i.e. this method) to
24- * guarantee the new API is available during feature-u validation.
25- *
26- * @return {string } NONE FOR US ... an error message when self is in an invalid state
27- * (falsy when valid).
28- *
29- * @private
30- */
31- function genesis ( ) {
32- logf ( 'genesis() registering internal Aspect properties' ) ;
33-
34- extendAspectProperty ( 'allowNoLogic$' ) ; // Aspect.allowNoLogic$: true || [{logicModules}]
35- // ... AI: technically this is for reducerAspect only (if the API ever supports this)
36- extendAspectProperty ( 'createLogicMiddleware$' ) ; // Aspect.createLogicMiddleware$(app, appLogic): reduxMiddleware
37- // ... AI: technically this is for reducerAspect only (if the API ever supports this)
38- }
39-
40-
4121/**
4222 * Validate self's aspect content on supplied feature.
4323 *
@@ -97,23 +77,23 @@ function assembleFeatureContent(app, activeFeatures) {
9777 else {
9878
9979 // by default, this is an error condition (when NOT overridden by client)
100- if ( ! this . allowNoLogic$ ) {
80+ if ( ! this . config . allowNoLogic$ ) {
10181 throw new Error ( '***ERROR*** feature-redux-logic found NO logic modules within your features ' +
10282 `... did you forget to register Feature.${ this . name } aspects in your features? ` +
10383 '(please refer to the feature-redux-logic docs to see how to override this behavior).' ) ;
10484 }
10585
10686 // when client override is an array, interpret it as logic modules
107- if ( Array . isArray ( this . allowNoLogic$ ) ) {
108- logf . force ( ' WARNING: NO logic modules were found in your Features (i.e. Feature.${this.name}), ' +
109- 'but client override (logicAspect.allowNoLogic$=[{logicModules}];) ' +
87+ if ( Array . isArray ( this . config . allowNoLogic$ ) ) {
88+ logf . force ( ` WARNING: NO logic modules were found in your Features (i.e. Feature.${ this . name } ), ` +
89+ 'but client override (logicAspect.config. allowNoLogic$=[{logicModules}];) ' +
11090 'directed a continuation WITH specified logic modules.' ) ;
111- appLogic = this . allowNoLogic$ ;
91+ appLogic = this . config . allowNoLogic$ ;
11292 }
11393 // otherwise, we simply disable redux-logic and continue on
11494 else {
115- logf . force ( ' WARNING: NO logic modules were found in your Features, ' +
116- 'but client override (logicAspect.allowNoLogic$=true ;) ' +
95+ logf . force ( ` WARNING: NO logic modules were found in your Features (i.e. Feature. ${ this . name } ), ` +
96+ 'but client override (logicAspect.config. allowNoLogic$=truthy ;) ' +
11797 'directed a continuation WITHOUT redux-logic.' ) ;
11898 }
11999 }
@@ -122,8 +102,8 @@ function assembleFeatureContent(app, activeFeatures) {
122102 // ... conditionally when we have logic modules
123103 // ... retained in self for promotion to feature-redux plugin
124104 if ( appLogic . length > 0 ) {
125- // ... accomplished in internal micro method (a defensive measure to allow easier overriding by client)
126- this . logicMiddleware = this . createLogicMiddleware$ ( app , appLogic ) ;
105+ // ... accomplished in internal config micro function (a defensive measure to allow easier overriding by client)
106+ this . logicMiddleware = this . config . createLogicMiddleware$ ( app , appLogic ) ;
127107 }
128108 // if we have no logic ... we have no middleware
129109 else {
@@ -133,8 +113,8 @@ function assembleFeatureContent(app, activeFeatures) {
133113
134114
135115/**
136- * An internal micro method that creates/returns the redux middleware
137- * for redux-logic.
116+ * An internal config micro function that creates/returns the
117+ * redux middleware for redux-logic.
138118 *
139119 * This logic is broken out in this internal method as a defensive
140120 * measure to make it easier for a client to override (if needed for
0 commit comments