Skip to content

Commit

Permalink
Added upload files support
Browse files Browse the repository at this point in the history
  • Loading branch information
grafitto committed Nov 19, 2018
1 parent f8b4624 commit ce0dfff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export const requests = {
getTags: 'data.getTags',
updateTag: 'data.updateTag',
getAppData: 'data.getAppData',
updateAppData: 'data.updateAppData'
updateAppData: 'data.updateAppData',
uploadFile: 'data.uploadFile',
},
toast: {
show: 'toast.show',
Expand Down
9 changes: 5 additions & 4 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export class Service {
private rpc(name: string, body: any) {
const reqId = Math.random();
return new Promise((resolve, reject) => {
this.rpcTracker[reqId] = {
resolve, reject
};
this.rpcTracker[reqId] = { resolve, reject };
const message = {
name,
body,
Expand All @@ -66,7 +64,10 @@ export class Service {
handler.rpcTracker[msg.id].resolve(msg.body);
} else {
handler.rpcTracker[msg.id].reject(msg.body);
}
}
// Remove the promise from the handler because
// it has already been taken care of.
// delete handler.rpcTracker[msg.id];
}
/**
* Emits a custom event
Expand Down
4 changes: 4 additions & 0 deletions tests/service.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Service, requests } from '..';
// @ts-ignore
import { request } from 'http';
//@ts-ignore
import jest from 'jest';

// @ts-ignore
jest.spyOn(global.window.parent , 'postMessage');

describe('Requests', async () => {
Expand Down

0 comments on commit ce0dfff

Please sign in to comment.