mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-10 17:33:36 +08:00
Summary: This makes the RCTEvent protocol more generic to make it easier to use the event coalescing feature for type of events other than components. This does a few other improvements that will be useful in follow up PRs. - Add `RCTComponentEvent` which is used instead of deprecated `[sendInputEventWithName:body:]` and remove that method completely (was only used at 2 places). - Make `coalescingKey` optional for events that return NO from `canCoalesce`. - Make `viewTag` optional for events that are not related to views. - Fast path for events that return NO from `canCoalesce`. - Add a missing test for event coalescing with different view tags. Ended up making only one PR for all this since the changes are related and hard to separate. **Migration** Use a custom RCTEvent subclass with `[sendEvent:]` (preferred way to allow type safe events) or `RCTComponentEvent`. **Test plan** - Ran RCTEventDispatcher unit tests - Tested manually in RNTester Changelog: [iOS] [Changed] - Remove deprecated RCTEvent method, sendInputEventWithName:body: Pull Request resolved: https://github.com/facebook/react-native/pull/15894 Reviewed By: shergin Differential Revision: D13726194 Pulled By: hramos fbshipit-source-id: 11f63a99e08f46ec6b4f16f8d9949cdbf5c3fe13
20 lines
615 B
Objective-C
20 lines
615 B
Objective-C
/**
|
|
* Copyright (c) Facebook, Inc. and its affilities.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <React/RCTEventDispatcher.h>
|
|
|
|
/**
|
|
* Generic untyped event for Components. Used internally by RCTDirectEventBlock and
|
|
* RCTBubblingEventBlock, for other use cases prefer using a class that implements
|
|
* RCTEvent to have a type safe way to initialize it.
|
|
*/
|
|
@interface RCTComponentEvent : NSObject<RCTEvent>
|
|
|
|
- (instancetype)initWithName:(NSString *)name viewTag:(NSNumber *)viewTag body:(NSDictionary *)body;
|
|
|
|
@end
|