I was trying to work with custom elements + NgRX and tried to integrate the custom element in an angularjs app. Whenever from my angularjs app I am calling the custom element exposed method change detection is not happening.
Calling code in angular js
const customElement= angular.element('hello-ce')[0];
customElement.refreshSettingProgressValue(settingsPage);
Exposed method in Angular 7 + @ngrx/store + Custom Elements:
ngOnInit(): void {
this.isLoading$ = this.store.pipe(select(landingPageQuery.getLoading));
this.categories$ = this.store.pipe(
select(landingPageQuery.getAllLandingPage)
);
}
@Input()
public refreshSettingProgressValue = function (this: CompType, settingCategoryCode: string) {
this.categories$.pipe(
mergeMap(categories => categories),
map(category => category.settings),
mergeMap(settings => settings),
filter(setting => setting.settingCodeType.code === settingCategoryCode),
take(1)
).subscribe({
next: (setting) => {
this.store.dispatch(new ResetSettingsProgressValue(setting));
this.store.dispatch(new LoadSettingsProgressValue(setting));
}
})
}.bind(this);
I tried calling the _refreshSettingProgressValue _ inside Angular7 app on click of a dummy button and everything works but when I call it outside Angular context I am not able to see the changes in UI. P.S LoadSettingsProgressValue has an effect where we call some api. I see the call is also happening and reducer is also updating the state but change detection doesn't seem to kick in.
I have already tried ngzone-element-strartergy but it didnt resolve my issue
ngDoBootstrap(): void {
const elements: any[] = [
[HelloWorldComponent, 'hello-ce'],
];
for (const [component, name] of elements) {
const strategyFactory = new ElementZoneStrategyFactory(component, this.injector);
const el = createCustomElement(component, { injector: this.injector, strategyFactory });
customElements.define(name, el);
}
}
I believe we can call changeDetection explicitly but with ngrx how and where can we do that?
Thanks