Skip to content

Commit b33ba03

Browse files
MOBILE-4802 block: Use new viewChild method
1 parent 32387d2 commit b33ba03

File tree

1 file changed

+3
-5
lines changed
  • src/core/features/block/components/block

1 file changed

+3
-5
lines changed

src/core/features/block/components/block/block.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { Component, Input, ViewChild, OnDestroy, Type, OnChanges, SimpleChanges } from '@angular/core';
15+
import { Component, Input, OnDestroy, Type, OnChanges, SimpleChanges, viewChild } from '@angular/core';
1616
import { CoreBlockDelegate } from '../../services/block-delegate';
1717
import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component';
1818
import { Subscription } from 'rxjs';
@@ -34,7 +34,7 @@ import { CoreSharedModule } from '@/core/shared.module';
3434
})
3535
export class CoreBlockComponent implements OnChanges, OnDestroy {
3636

37-
@ViewChild(CoreDynamicComponent) dynamicComponent?: CoreDynamicComponent<ICoreBlockComponent>;
37+
readonly dynamicComponent = viewChild<CoreDynamicComponent<ICoreBlockComponent>>(CoreDynamicComponent);
3838

3939
@Input({ required: true }) block!: CoreCourseBlock; // The block to render.
4040
@Input({ required: true }) contextLevel!: ContextLevel; // The context where the block will be used.
@@ -118,9 +118,7 @@ export class CoreBlockComponent implements OnChanges, OnDestroy {
118118
* @returns Promise resolved when done.
119119
*/
120120
async invalidate(): Promise<void> {
121-
if (this.dynamicComponent) {
122-
await this.dynamicComponent.callComponentMethod('invalidateContent');
123-
}
121+
await this.dynamicComponent()?.callComponentMethod('invalidateContent');
124122
}
125123

126124
}

0 commit comments

Comments
 (0)