iOS: impl iosUsingObject option
This commit is contained in:
parent
dc016b9507
commit
f2cd693fa9
@ -46,6 +46,7 @@ - (dispatch_queue_t)syncQueue {
|
|||||||
- (void)publish:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
|
- (void)publish:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
|
||||||
NSString *biz = [dic optString:@"biz"];
|
NSString *biz = [dic optString:@"biz"];
|
||||||
NSString *name = [dic optString:@"name"];
|
NSString *name = [dic optString:@"name"];
|
||||||
|
BOOL usingObject = [dic optBool:@"iosUsingObject"];
|
||||||
if (biz) {
|
if (biz) {
|
||||||
name = [NSString stringWithFormat:@"__doric__%@#%@", biz, name];
|
name = [NSString stringWithFormat:@"__doric__%@#%@", biz, name];
|
||||||
}
|
}
|
||||||
@ -58,13 +59,18 @@ - (void)publish:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
|
|||||||
options:NSJSONReadingMutableContainers
|
options:NSJSONReadingMutableContainers
|
||||||
error:&err];
|
error:&err];
|
||||||
}
|
}
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:dataDic];
|
if (usingObject) {
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:name object:dataDic userInfo:nil];
|
||||||
|
} else {
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:dataDic];
|
||||||
|
}
|
||||||
[promise resolve:nil];
|
[promise resolve:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)subscribe:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
|
- (void)subscribe:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
|
||||||
NSString *biz = [dic optString:@"biz"];
|
NSString *biz = [dic optString:@"biz"];
|
||||||
NSString *name = [dic optString:@"name"];
|
NSString *name = [dic optString:@"name"];
|
||||||
|
BOOL usingObject = [dic optBool:@"iosUsingObject"];
|
||||||
if (biz) {
|
if (biz) {
|
||||||
name = [NSString stringWithFormat:@"__doric__%@#%@", biz, name];
|
name = [NSString stringWithFormat:@"__doric__%@#%@", biz, name];
|
||||||
}
|
}
|
||||||
@ -77,7 +83,7 @@ - (void)subscribe:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
|
|||||||
usingBlock:^(NSNotification *note) {
|
usingBlock:^(NSNotification *note) {
|
||||||
__strong typeof(_self) self = _self;
|
__strong typeof(_self) self = _self;
|
||||||
DoricPromise *currentPromise = [[DoricPromise alloc] initWithContext:self.doricContext callbackId:callbackId];
|
DoricPromise *currentPromise = [[DoricPromise alloc] initWithContext:self.doricContext callbackId:callbackId];
|
||||||
[currentPromise resolve:note.userInfo];
|
[currentPromise resolve:usingObject ? note.object : note.userInfo];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
dispatch_barrier_async(self.syncQueue, ^{
|
dispatch_barrier_async(self.syncQueue, ^{
|
||||||
|
Reference in New Issue
Block a user