fix(core): update

This commit is contained in:
2020-10-06 15:56:00 +00:00
commit 8241e641a9
15 changed files with 11782 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import { TypedRequest } from '@apiglobal/typedrequest';
import * as plugins from './dees-comms.plugins';
/**
* a comm class for client side communication between workers and tabs.
*/
export class DeesComms {
// sending messages
private postChannel = new BroadcastChannel('dees-comms');
private typedrouter = new plugins.typedrequest.TypedRouter();
private subscriptionChannel = new BroadcastChannel('dees-comms');
constructor() {
this.subscriptionChannel.onmessage = (eventArg) => {
const message = eventArg.data;
this.typedrouter.routeAndAddResponse(message);
};
}
/**
* creates a typedrequest with this classes postMessage as postMethod
*/
public createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest>(
methodName: T['method']
): TypedRequest<T> {
const typedrequest = new plugins.typedrequest.TypedRequest(this.postMessage, methodName, this.typedrouter);
return typedrequest;
}
/**
* posts a typedrequestmessage
*/
public async postMessage<T = plugins.typedrequestInterfaces.ITypedRequest>(
messageArg: T
): Promise<void> {
this.postChannel.postMessage(messageArg);
}
/**
* subscribe to messages
*/
public async subscribe() {}
}

View File

@@ -0,0 +1,6 @@
import * as plugins from './dees-comms.plugins';
/**
* a message that can be sent
*/
export class DeesCommsMessage {}

5
ts/dees-comms.plugins.ts Normal file
View File

@@ -0,0 +1,5 @@
// pushrocks scope
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
import * as typedrequest from '@apiglobal/typedrequest';
export { typedrequestInterfaces, typedrequest };

11
ts/index.ts Normal file
View File

@@ -0,0 +1,11 @@
import * as plugins from './dees-comms.plugins';
/**
* a comm class for client side communication between workers and tabs.
*/
export class DeesComms {
public postChannel = new BroadcastChannel('dees-comms');
public subscriptionChannel = new BroadcastChannel('dees-comms');
public async postMessage() {}
}