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:
parent
8f07b01ac8
commit
a496baa68c
|
@ -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];
|
||||
|
|
|
@ -48,6 +48,7 @@ RCT_EXTERN NSString *RCTNormalizeInputEventName(NSString *eventName);
|
|||
|
||||
@property (nonatomic, strong, readonly) NSNumber *viewTag;
|
||||
@property (nonatomic, copy, readonly) NSString *eventName;
|
||||
@property (nonatomic, assign, readonly) uint16_t coalescingKey;
|
||||
|
||||
- (BOOL)canCoalesce;
|
||||
- (id<RCTEvent>)coalesceWithEvent:(id<RCTEvent>)newEvent;
|
||||
|
@ -95,7 +96,7 @@ RCT_EXTERN NSString *RCTNormalizeInputEventName(NSString *eventName);
|
|||
|
||||
/**
|
||||
* Send a pre-prepared event object.
|
||||
*
|
||||
*
|
||||
* If the event can be coalesced it is added to a pool of events that are sent at the beginning of the next js frame.
|
||||
* Otherwise if the event cannot be coalesced we first flush the pool of coalesced events and the new event after that.
|
||||
*
|
||||
|
|
|
@ -30,7 +30,9 @@ static NSNumber *RCTGetEventID(id<RCTEvent> event)
|
|||
{
|
||||
return @(
|
||||
event.viewTag.intValue |
|
||||
(((uint64_t)event.eventName.hash & 0xFFFF) << 32));
|
||||
(((uint64_t)event.eventName.hash & 0xFFFF) << 32) |
|
||||
(((uint64_t)event.coalescingKey) << 48)
|
||||
);
|
||||
}
|
||||
|
||||
@interface RCTEventDispatcher() <RCTFrameUpdateObserver>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
@synthesize eventName = _eventName;
|
||||
@synthesize viewTag = _viewTag;
|
||||
@synthesize coalescingKey = _coalescingKey;
|
||||
|
||||
- (instancetype)initWithEventName:(NSString *)eventName
|
||||
reactTouches:(NSArray<NSDictionary *> *)reactTouches
|
||||
|
|
|
@ -59,6 +59,11 @@ CGFloat const ZINDEX_STICKY_HEADER = 50;
|
|||
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
|
||||
- (uint16_t)coalescingKey
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSDictionary *)body
|
||||
{
|
||||
NSDictionary *body = @{
|
||||
|
|
Loading…
Reference in New Issue