Skip to content

Commit

Permalink
Put some TODOs in for tomorrow
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnvc committed Nov 2, 2018
1 parent eca6e73 commit 436a09a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/ios/CDVServiceWorker.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,24 @@ - (void)prepareJavascriptContext
encoding:NSUTF8StringEncoding
error:nil];
[self.jsContext evaluateScript:shimScript];
self.jsContext[@"cache"][@"match"] = ^(id requestOrURL){

self.jsContext[@"fetch"] = ^(JSValue *request) {
// TODO
};

self.jsContext[@"cache"][@"match"] = ^(id requestOrURL) {
NSLog(@"SW: CHECKING FOR MATCH WITH %@", requestOrURL);
JSValue* promiseClass = self.jsContext[@"Promise"];
JSPromiseCallback cb = ^(JSValue* resolve, JSValue *reject) {
JSValue *promiseClass = self.jsContext[@"Promise"];
JSPromiseCallback cb = ^(JSValue *resolve, JSValue *reject) {
[self.commandDelegate runInBackground:^{
JSValue *resp = [self requestFromCache:requestOrURL];
[resolve callWithArguments:@[resp]];
[resolve callWithArguments:@[ resp ]];
}];
};
JSValue *respPromise = [promiseClass constructWithArguments:@[cb]];
JSValue *respPromise = [promiseClass constructWithArguments:@[ cb ]];
return respPromise;
};

self.jsContext[@"cache"][@"add"] = ^(id requestOrURL){
NSLog(@"SW: ADDING request %@", requestOrURL);
};
Expand Down Expand Up @@ -114,6 +120,11 @@ - (void)serviceWorkerReady:(CDVInvokedUrlCommand*)command
- (void)postMessage:(CDVInvokedUrlCommand*)command
{
NSLog(@"Posting message");
// TODO: have ports array replaced with some sort of identifier,
// put corresponding objects int he array with a `postMessage`
// method that will let us keep track of what was posted, then
// return that to the invoked command, so it can handle it on that
// side
[self.commandDelegate runInBackground:^{
NSDictionary *event = @{@"data": [command argumentAtIndex:0],
@"ports": [command argumentAtIndex:1]};
Expand Down

0 comments on commit 436a09a

Please sign in to comment.