-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathPHHandler.m
39 lines (24 loc) · 834 Bytes
/
PHHandler.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Phoenix is released under the MIT License. Refer to https://github.com/kasper/phoenix/blob/master/LICENSE.md
*/
#import "PHHandler.h"
@interface PHHandler ()
@property JSManagedValue *callback;
@end
@implementation PHHandler
#pragma mark - Callback
- (void) manageCallback:(JSValue *)callback {
self.callback = [JSManagedValue managedValueWithValue:callback andOwner:self];
}
#pragma mark - Call
- (void) callWithArguments:(NSArray *)arguments {
// Create a new scope for callback
JSValue *callback = self.callback.value;
JSContext *scope = [[JSContext alloc] initWithVirtualMachine:callback.context.virtualMachine];
JSValue *function = [JSValue valueWithObject:callback inContext:scope];
[function callWithArguments:arguments];
}
- (void) call {
[self callWithArguments:@[]];
}
@end