Skip to content

Commit

Permalink
refactor(globaltransport): refactor GlobalTransport in fronts-transport
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Jun 19, 2021
1 parent d442fcf commit 73b78d3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/fronts-react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { boot, loadScript, transport } from 'fronts';
export { boot, loadScript, globalTransport, GlobalTransport } from 'fronts';

export * from './useApp';
export * from './interface';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import { ListenerOptions, Transport, TransportOptions } from 'data-transport';
import { postMessageToFrames } from './postMessage';

interface MessageTransportOptions extends Partial<TransportOptions> {
interface EventTransportOptions extends Partial<TransportOptions> {
/**
* Specify what the origin of targetWindow must be for the event to be dispatched,
* by default, it's the literal string "*" (indicating no preference).
*/
targetOrigin?: string;
}

class MessageTransport<T = {}> extends Transport<T> {
export class GlobalTransport<T = any> extends Transport<T> {
constructor({
targetOrigin = '*',
listener = (callback) => {
Expand All @@ -29,7 +29,7 @@ class MessageTransport<T = {}> extends Transport<T> {
},
checkListen = false,
...options
}: MessageTransportOptions) {
}: EventTransportOptions) {
super({
...options,
checkListen,
Expand All @@ -39,4 +39,4 @@ class MessageTransport<T = {}> extends Transport<T> {
}
}

export const transport = new MessageTransport({});
export const globalTransport = new GlobalTransport({});
2 changes: 1 addition & 1 deletion packages/fronts-transport/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from 'data-transport';

export * from './messageTransport';
export * from './globalTransport';
2 changes: 1 addition & 1 deletion packages/fronts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './injectDependencies';

export { transport } from 'fronts-transport';
export { globalTransport, GlobalTransport } from 'fronts-transport';

export * from './loadApp';
export * from './interface';
Expand Down

0 comments on commit 73b78d3

Please sign in to comment.