forked from stashapp/stash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement UI event dispatcher/listener (stashapp#4492)
* page change event * expose event to plugin api * Update UIPluginApi.md * Add to example plugin --------- Co-authored-by: WithoutPants <[email protected]>
- Loading branch information
Showing
5 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class StashEvent extends EventTarget { | ||
dispatch(event: string, id?: string, data?: object) { | ||
event = `stash:${event}${id ? `:${id}` : ""}`; | ||
|
||
this.dispatchEvent( | ||
new CustomEvent(event, { | ||
detail: { | ||
event: event, | ||
...(id ? { id } : {}), | ||
...(data ? { data } : {}), | ||
}, | ||
}) | ||
); | ||
} | ||
} | ||
|
||
const Event = new StashEvent(); | ||
|
||
export default Event; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters