Skip to content

Commit

Permalink
🐛 fix: fetchPluginMessage 支持定义出参泛型
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Sep 5, 2023
1 parent b47e60f commit e3059da
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/render/message.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { PluginChannel } from './const';
import { onReceiveData } from './utils';

export const fetchPluginMessage = () =>
new Promise<any>((resolve) => {
export const fetchPluginMessage = <T = any>() =>
new Promise<T>((resolve) => {
const receiverData = (e: MessageEvent) => {
onReceiveData(e, (data) => {
resolve(data.content);
resolve(data.content as T);
window.removeEventListener('message', receiverData);
});
};
Expand Down

0 comments on commit e3059da

Please sign in to comment.