| 160 | } |
| 161 | |
| 162 | run(): T { |
| 163 | // TODO cleanupEffect |
| 164 | |
| 165 | if (!(this.flags & EffectFlags.ACTIVE)) { |
| 166 | // stopped during cleanup |
| 167 | return this.fn() |
| 168 | } |
| 169 | |
| 170 | this.flags |= EffectFlags.RUNNING |
| 171 | cleanupEffect(this) |
| 172 | prepareDeps(this) |
| 173 | const prevEffect = activeSub |
| 174 | const prevShouldTrack = shouldTrack |
| 175 | activeSub = this |
| 176 | shouldTrack = true |
| 177 | |
| 178 | try { |
| 179 | return this.fn() |
| 180 | } finally { |
| 181 | if (__DEV__ && activeSub !== this) { |
| 182 | warn( |
| 183 | 'Active effect was not restored correctly - ' + |
| 184 | 'this is likely a Vue internal bug.', |
| 185 | ) |
| 186 | } |
| 187 | cleanupDeps(this) |
| 188 | activeSub = prevEffect |
| 189 | shouldTrack = prevShouldTrack |
| 190 | this.flags &= ~EffectFlags.RUNNING |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | stop(): void { |
| 195 | if (this.flags & EffectFlags.ACTIVE) { |