Hi, we are using TS embedded in our

Hi, we are using TS embedded in our application, and we're facing issues with updating filters programmatically after the liveboard has loaded. We utilize HostEvent.UpdateFilters for this purpose, but the problem is that triggering it on the EmbedEvent.LiveboardRendered event doesn’t update the liveboard because the charts aren’t completely loaded yet. Consequently, we have resorted to using setTimeout to delay the UpdateFilters process, which is not an ideal solution. The time needed for the timeout varies and can lead to errors in some cases (Please check the code snippet below). I’m wondering if there’s an event that indicates when the liveboard, including all charts and contents, is fully loaded. Alternatively, are there any other solutions to address this issue?
embed.on(EmbedEvent.LiveboardRendered, () => {
setTimeout(() => {
embed.trigger(HostEvent.UpdateFilters, {
filter: {
column: "Currency",
oper: "EQ",
values: [window.defaultCurrency]
}
})
}, 500);
});
embed.on(EmbedEvent.LiveboardRendered, () => {
setTimeout(() => {
embed.trigger(HostEvent.UpdateFilters, {
filter: {
column: "Currency",
oper: "EQ",
values: [window.defaultCurrency]
}
})
}, 500);
});
8 Replies
shikharTS
shikharTS4mo ago
checking
shikharTS
shikharTS4mo ago
Maybe you can use this embed event? https://developers.thoughtspot.com/docs/Enumeration_EmbedEvent#_data to see when the data is loaded for the liveboard embed?
EmbedEvent
Event types emitted by the embedded ThoughtSpot application.
shikharTS
shikharTS4mo ago
Let me check if there are better ways to do this Also maybe you can use init with runtime filters for your use-case?
Farzaneh
FarzanehOP4mo ago
Yea I tried that before. When using EmbedEvent.Data it keeps updating the filter and never stops runtime filters doesn't work in this case since it filters the whole data so other values in the filter won't be available for users after that. We need to select one value in the filter and have other values available for users to select
shikharTS
shikharTS4mo ago
Yeah I think just listen for the first data event and then update filters and stop listening. Since data event is emitted on every data load, if you keep listening to it, it will update filters, fire a new data call and then update filters again going in an endless loop
Farzaneh
FarzanehOP4mo ago
Yea let me try it I updated my code to this and seems to be working well:
const handleDataEvent = () => {
embed.trigger(HostEvent.UpdateFilters, {
filter: {
column: "Currency",
oper: "EQ",
values: [window.defaultCurrency]
}
});
embed.off(EmbedEvent.Data, handleDataEvent);
};

embed.on(EmbedEvent.Data, handleDataEvent);
const handleDataEvent = () => {
embed.trigger(HostEvent.UpdateFilters, {
filter: {
column: "Currency",
oper: "EQ",
values: [window.defaultCurrency]
}
});
embed.off(EmbedEvent.Data, handleDataEvent);
};

embed.on(EmbedEvent.Data, handleDataEvent);
shikharTS
shikharTS4mo ago
Yes this looks good.
Farzaneh
FarzanehOP4mo ago
Thank you!

Did you find this page helpful?