reintroduced coalescing key for events

Summary: This was previously removed in D2884587, but we will need it going forward. See D3092867 for reasons why it's necessary again.

Reviewed By: javache

Differential Revision: D3092848

fb-gh-sync-id: 0d10dbac4148fcc8e035d32d8eab50f876d99e88
fbshipit-source-id: 0d10dbac4148fcc8e035d32d8eab50f876d99e88
This commit is contained in:
Martin Kralik
2016-04-01 06:53:04 -07:00
committed by Facebook Github Bot 8
parent 8f07b01ac8
commit a496baa68c
5 changed files with 25 additions and 7 deletions

View File

@@ -29,14 +29,19 @@
@synthesize viewTag = _viewTag;
@synthesize eventName = _eventName;
@synthesize coalescingKey = _coalescingKey;
- (instancetype)initWithViewTag:(NSNumber *)viewTag eventName:(NSString *)eventName body:(NSDictionary<NSString *, id> *)body
- (instancetype)initWithViewTag:(NSNumber *)viewTag
eventName:(NSString *)eventName
body:(NSDictionary<NSString *, id> *)body
coalescingKey:(uint16_t)coalescingKey
{
if (self = [super init]) {
_viewTag = viewTag;
_eventName = eventName;
_body = body;
_canCoalesce = YES;
_coalescingKey = coalescingKey;
}
return self;
}
@@ -85,7 +90,8 @@
_body = @{ @"foo": @"bar" };
_testEvent = [[RCTTestEvent alloc] initWithViewTag:nil
eventName:_eventName
body:_body];
body:_body
coalescingKey:0];
_JSMethod = [[_testEvent class] moduleDotMethod];
}
@@ -127,7 +133,8 @@
{
RCTTestEvent *nonCoalescingEvent = [[RCTTestEvent alloc] initWithViewTag:nil
eventName:_eventName
body:@{}];
body:@{}
coalescingKey:0];
nonCoalescingEvent.canCoalesce = NO;
[_eventDispatcher sendEvent:_testEvent];
@@ -144,7 +151,8 @@
{
RCTTestEvent *ignoredEvent = [[RCTTestEvent alloc] initWithViewTag:nil
eventName:_eventName
body:@{ @"other": @"body" }];
body:@{ @"other": @"body" }
coalescingKey:0];
[_eventDispatcher sendEvent:ignoredEvent];
[_eventDispatcher sendEvent:_testEvent];
@@ -162,7 +170,8 @@
NSString *firstEventName = RCTNormalizeInputEventName(@"firstEvent");
RCTTestEvent *firstEvent = [[RCTTestEvent alloc] initWithViewTag:nil
eventName:firstEventName
body:_body];
body:_body
coalescingKey:0];
[_eventDispatcher sendEvent:firstEvent];
[_eventDispatcher sendEvent:_testEvent];