2015-03-23 20:28:42 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-03-23 20:28:42 +00:00
|
|
|
*/
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
2016-11-23 15:47:52 +00:00
|
|
|
#import <React/RCTBridge.h>
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2016-04-28 14:43:24 +00:00
|
|
|
typedef NS_ENUM(NSInteger, RCTTextEventType)
|
|
|
|
{
|
2015-02-20 04:10:52 +00:00
|
|
|
RCTTextEventTypeFocus,
|
|
|
|
RCTTextEventTypeBlur,
|
|
|
|
RCTTextEventTypeChange,
|
|
|
|
RCTTextEventTypeSubmit,
|
2015-11-02 17:13:41 +00:00
|
|
|
RCTTextEventTypeEnd,
|
|
|
|
RCTTextEventTypeKeyPress
|
2015-02-20 04:10:52 +00:00
|
|
|
};
|
|
|
|
|
2015-08-11 13:37:12 +00:00
|
|
|
/**
|
|
|
|
* The threshold at which text inputs will start warning that the JS thread
|
|
|
|
* has fallen behind (resulting in poor input performance, missed keys, etc.)
|
|
|
|
*/
|
|
|
|
RCT_EXTERN const NSInteger RCTTextUpdateLagWarningThreshold;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Takes an input event name and normalizes it to the form that is required
|
|
|
|
* by the events system (currently that means starting with the "top" prefix,
|
|
|
|
* but that's an implementation detail that may change in future).
|
|
|
|
*/
|
|
|
|
RCT_EXTERN NSString *RCTNormalizeInputEventName(NSString *eventName);
|
2015-07-21 19:37:24 +00:00
|
|
|
|
2015-05-28 03:15:33 +00:00
|
|
|
@protocol RCTEvent <NSObject>
|
|
|
|
@required
|
|
|
|
|
|
|
|
@property (nonatomic, strong, readonly) NSNumber *viewTag;
|
|
|
|
@property (nonatomic, copy, readonly) NSString *eventName;
|
2016-04-01 13:53:04 +00:00
|
|
|
@property (nonatomic, assign, readonly) uint16_t coalescingKey;
|
2015-05-28 03:15:33 +00:00
|
|
|
|
|
|
|
- (BOOL)canCoalesce;
|
|
|
|
- (id<RCTEvent>)coalesceWithEvent:(id<RCTEvent>)newEvent;
|
|
|
|
|
2016-02-03 13:22:14 +00:00
|
|
|
// used directly for doing a JS call
|
2015-05-28 03:15:33 +00:00
|
|
|
+ (NSString *)moduleDotMethod;
|
2016-02-03 13:22:14 +00:00
|
|
|
// must contain only JSON compatible values
|
|
|
|
- (NSArray *)arguments;
|
2015-05-28 03:15:33 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2016-11-01 10:56:50 +00:00
|
|
|
/**
|
|
|
|
* This protocol allows observing events dispatched by RCTEventDispatcher.
|
|
|
|
*/
|
|
|
|
@protocol RCTEventDispatcherObserver <NSObject>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called before dispatching an event, on the same thread the event was
|
2016-11-23 13:35:34 +00:00
|
|
|
* dispatched from.
|
2016-11-01 10:56:50 +00:00
|
|
|
*/
|
2016-11-23 13:35:34 +00:00
|
|
|
- (void)eventDispatcherWillDispatchEvent:(id<RCTEvent>)event;
|
2016-11-01 10:56:50 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-05-28 03:15:33 +00:00
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
/**
|
|
|
|
* This class wraps the -[RCTBridge enqueueJSCall:args:] method, and
|
|
|
|
* provides some convenience methods for generating event calls.
|
|
|
|
*/
|
2015-08-25 11:27:09 +00:00
|
|
|
@interface RCTEventDispatcher : NSObject <RCTBridgeModule>
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-23 16:08:51 +00:00
|
|
|
* Deprecated, do not use.
|
2015-02-20 04:10:52 +00:00
|
|
|
*/
|
2016-05-23 16:08:51 +00:00
|
|
|
- (void)sendAppEventWithName:(NSString *)name body:(id)body
|
|
|
|
__deprecated_msg("Subclass RCTEventEmitter instead");
|
2015-02-24 17:06:57 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-23 16:08:51 +00:00
|
|
|
* Deprecated, do not use.
|
2015-02-24 17:06:57 +00:00
|
|
|
*/
|
2016-05-23 16:08:51 +00:00
|
|
|
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body
|
|
|
|
__deprecated_msg("Subclass RCTEventEmitter instead");
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-23 16:08:51 +00:00
|
|
|
* Deprecated, do not use.
|
2015-02-20 04:10:52 +00:00
|
|
|
*/
|
2016-05-23 16:08:51 +00:00
|
|
|
- (void)sendInputEventWithName:(NSString *)name body:(NSDictionary *)body
|
|
|
|
__deprecated_msg("Use RCTDirectEventBlock or RCTBubblingEventBlock instead");
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-23 16:08:51 +00:00
|
|
|
* Send a text input/focus event. For internal use only.
|
2015-02-20 04:10:52 +00:00
|
|
|
*/
|
|
|
|
- (void)sendTextEventWithType:(RCTTextEventType)type
|
|
|
|
reactTag:(NSNumber *)reactTag
|
2015-07-21 19:37:24 +00:00
|
|
|
text:(NSString *)text
|
2015-11-02 17:13:41 +00:00
|
|
|
key:(NSString *)key
|
2015-07-21 19:37:24 +00:00
|
|
|
eventCount:(NSInteger)eventCount;
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-08-11 13:37:12 +00:00
|
|
|
/**
|
|
|
|
* Send a pre-prepared event object.
|
2016-04-01 13:53:04 +00:00
|
|
|
*
|
2016-04-03 06:30:26 +00:00
|
|
|
* Events are sent to JS as soon as the thread is free to process them.
|
|
|
|
* If an event can be coalesced and there is another compatible event waiting, the coalescing will happen immediately.
|
2015-08-11 13:37:12 +00:00
|
|
|
*/
|
2015-05-28 03:15:33 +00:00
|
|
|
- (void)sendEvent:(id<RCTEvent>)event;
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2016-11-01 10:56:50 +00:00
|
|
|
/**
|
|
|
|
* Add an event dispatcher observer.
|
|
|
|
*/
|
|
|
|
- (void)addDispatchObserver:(id<RCTEventDispatcherObserver>)observer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an event dispatcher observer.
|
|
|
|
*/
|
|
|
|
- (void)removeDispatchObserver:(id<RCTEventDispatcherObserver>)observer;
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
@end
|
2016-04-28 12:47:29 +00:00
|
|
|
|
|
|
|
@interface RCTBridge (RCTEventDispatcher)
|
|
|
|
|
|
|
|
- (RCTEventDispatcher *)eventDispatcher;
|
|
|
|
|
|
|
|
@end
|