RCTComponentEvent.m 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import "RCTComponentEvent.h"
  8. #import "RCTAssert.h"
  9. @implementation RCTComponentEvent {
  10. NSArray *_arguments;
  11. }
  12. @synthesize eventName = _eventName;
  13. @synthesize viewTag = _viewTag;
  14. - (instancetype)initWithName:(NSString *)name viewTag:(NSNumber *)viewTag body:(NSDictionary *)body
  15. {
  16. if (self = [super init]) {
  17. NSMutableDictionary *mutableBody = [NSMutableDictionary dictionaryWithDictionary:body];
  18. mutableBody[@"target"] = viewTag;
  19. _eventName = RCTNormalizeInputEventName(name);
  20. _viewTag = viewTag;
  21. _arguments = @[ _viewTag, _eventName, mutableBody ];
  22. }
  23. return self;
  24. }
  25. RCT_NOT_IMPLEMENTED(-(instancetype)init)
  26. - (NSArray *)arguments
  27. {
  28. return _arguments;
  29. }
  30. - (BOOL)canCoalesce
  31. {
  32. return NO;
  33. }
  34. + (NSString *)moduleDotMethod
  35. {
  36. return @"RCTEventEmitter.receiveEvent";
  37. }
  38. @end