()
| 163 | #currentEffectRef: EffectRef | null = null |
| 164 | |
| 165 | render() { |
| 166 | if (this.#shouldRecreateEntireView() && this.#currentEffectRef) { |
| 167 | this.#currentEffectRef.destroy() |
| 168 | this.#currentEffectRef = null |
| 169 | this.renderFlags &= ~FlexRenderFlags.RenderEffectChecked |
| 170 | } |
| 171 | |
| 172 | this.viewContainerRef.clear() |
| 173 | this.renderFlags = |
| 174 | FlexRenderFlags.Pristine | |
| 175 | (this.renderFlags & FlexRenderFlags.ViewFirstRender) | |
| 176 | (this.renderFlags & FlexRenderFlags.RenderEffectChecked) |
| 177 | |
| 178 | const resolvedContent = this.#getContentValue() |
| 179 | if (resolvedContent.kind === 'null') { |
| 180 | this.renderView = null |
| 181 | } else { |
| 182 | this.renderView = this.#renderViewByContent(resolvedContent) |
| 183 | } |
| 184 | |
| 185 | // If the content is a function `content(props)`, we initialize an effect |
| 186 | // in order to react to changes if the given definition use signals. |
| 187 | if (!this.#currentEffectRef && typeof this.content === 'function') { |
| 188 | this.#currentEffectRef = effect( |
| 189 | () => { |
| 190 | this.#latestContent() |
| 191 | if (!(this.renderFlags & FlexRenderFlags.RenderEffectChecked)) { |
| 192 | this.renderFlags |= FlexRenderFlags.RenderEffectChecked |
| 193 | return |
| 194 | } |
| 195 | this.renderFlags |= FlexRenderFlags.DirtySignal |
| 196 | // This will mark the view as changed, |
| 197 | // so we'll try to check for updates into ngDoCheck |
| 198 | this.#changeDetectorRef.markForCheck() |
| 199 | }, |
| 200 | { injector: this.viewContainerRef.injector }, |
| 201 | ) |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | #shouldRecreateEntireView() { |
| 206 | return ( |
no test coverage detected