Implement UI event dispatcher/listener (#4492)

* page change event
* expose event to plugin api
* Update UIPluginApi.md
* Add to example plugin
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
Raghavan
2024-02-27 03:57:28 +05:30
committed by GitHub
parent 56896d7c7d
commit 6a9175c954
5 changed files with 40 additions and 0 deletions

View File

@@ -1,6 +1,9 @@
interface IPluginApi {
React: typeof React;
GQL: any;
Event: {
addEventListener: (event: string, callback: (e: CustomEvent) => void) => void;
};
libraries: {
ReactRouterDOM: {
Link: React.FC<any>;
@@ -53,6 +56,8 @@ interface IPluginApi {
NavUtils
} = PluginApi.utils;
PluginApi.Event.addEventListener("stash:location", (e) => console.log("Page Changed", e.detail.data.location.pathname, e.detail.data.location.search))
const ScenePerformer: React.FC<{
performer: any;
}> = ({ performer }) => {