@@ -9,6 +9,11 @@ import IdGenerator from './IdGenerator.mjs';
99 * @class Neo.core.Effect
1010 */
1111class Effect {
12+ /**
13+ * The optional component id this effect belongs to.
14+ * @member {String|null} componentId=null
15+ */
16+ componentId = null
1217 /**
1318 * A Map containing Config instances as keys and their cleanup functions as values.
1419 * @member {Map} dependencies=new Map()
@@ -17,9 +22,9 @@ class Effect {
1722 dependencies = new Map ( )
1823 /**
1924 * The function to execute.
20- * @member {Function|null} _fn =null
25+ * @member {Function|null} fn =null
2126 */
22- _fn = null
27+ fn = null
2328 /**
2429 * The unique identifier for this effect instance.
2530 * @member {String|null}
@@ -52,9 +57,14 @@ class Effect {
5257
5358 /**
5459 * @param {Function } fn The function to execute for the effect.
60+ * @param {String } [componentId] The component id this effect belongs to.
5561 */
56- constructor ( fn ) {
57- this . fn = fn
62+ constructor ( fn , componentId ) {
63+ this . fn = fn ;
64+
65+ if ( componentId ) {
66+ this . componentId = componentId
67+ }
5868 }
5969
6070 /**
@@ -96,7 +106,7 @@ class Effect {
96106 me . fn ( )
97107 } finally {
98108 EffectManager . pop ( ) ;
99- me . isRunning = false ;
109+ me . isRunning = false
100110 }
101111 }
102112
@@ -124,8 +134,8 @@ const ns = Neo.ns('Neo.core', true);
124134ns . Effect = Effect ;
125135
126136// Register a shortcut to the Neo namespace
127- Neo . effect = function ( fn ) {
128- return new Effect ( fn )
137+ Neo . effect = function ( fn , id ) {
138+ return new Effect ( fn , id )
129139}
130140
131141export default Effect ;
0 commit comments