Skip to content

Commit f3ef390

Browse files
committed
use executeAfterLoad
1 parent ca4efcf commit f3ef390

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

src/embed/ts-embed.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -481,36 +481,11 @@ export class TsEmbed {
481481
notifyAuthFailure(AuthFailureType.IDLE_SESSION_TIMEOUT);
482482
};
483483

484-
private pendingEvents: Array<{ eventType: HostEvent, data: TriggerPayload<any, HostEvent>, onEventTriggered?: () => void }> = [];
485-
486-
private executePendingEvents() {
487-
logger.debug('executePendingEvents', this.pendingEvents);
488-
setTimeout(() => {
489-
this.pendingEvents.forEach((event) => {
490-
this.trigger(event.eventType, event.data);
491-
event.onEventTriggered?.();
492-
});
493-
this.pendingEvents = [];
494-
}, 1000);
495-
}
496-
protected triggerAfterLoad(eventType: HostEvent, data: TriggerPayload<any, HostEvent>, onEventTriggered?: () => void) {
497-
if (this.checkEmbedContainerLoaded()) {
498-
this.trigger(eventType, data);
499-
onEventTriggered?.();
500-
} else {
501-
this.pendingEvents.push({ eventType, data, onEventTriggered });
502-
}
503-
}
504-
505484
/**
506485
* Register APP_INIT event and sendback init payload
507486
*/
508487
private registerAppInit = () => {
509488
this.on(EmbedEvent.APP_INIT, this.appInitCb, { start: false }, true);
510-
this.on(EmbedEvent.AuthInit, () => {
511-
this.isEmbedContainerLoaded = true;
512-
this.executePendingEvents();
513-
}, { start: false }, true);
514489
this.on(EmbedEvent.AuthExpire, this.updateAuthToken, { start: false }, true);
515490
this.on(EmbedEvent.IdleSessionTimeout, this.idleSessionTimeout, { start: false }, true);
516491

@@ -1431,7 +1406,9 @@ export class TsEmbed {
14311406
}
14321407
this.validatePreRenderViewConfig(this.viewConfig);
14331408
logger.debug('triggering UpdateEmbedParams', this.viewConfig);
1434-
this.triggerAfterLoad(HostEvent.UpdateEmbedParams, this.getUpdateEmbedParamsObject());
1409+
this.executeAfterEmbedContainerLoaded(() => {
1410+
this.trigger(HostEvent.UpdateEmbedParams, this.getUpdateEmbedParamsObject());
1411+
});
14351412
}
14361413

14371414
this.beforePrerenderVisible();

0 commit comments

Comments
 (0)