RCTBridgeMethod.h 924 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 <Foundation/Foundation.h>
  8. @class RCTBridge;
  9. typedef NS_ENUM(NSUInteger, RCTFunctionType) {
  10. RCTFunctionTypeNormal,
  11. RCTFunctionTypePromise,
  12. RCTFunctionTypeSync,
  13. };
  14. static inline const char *RCTFunctionDescriptorFromType(RCTFunctionType type) {
  15. switch (type) {
  16. case RCTFunctionTypeNormal:
  17. return "async";
  18. case RCTFunctionTypePromise:
  19. return "promise";
  20. case RCTFunctionTypeSync:
  21. return "sync";
  22. }
  23. };
  24. @protocol RCTBridgeMethod <NSObject>
  25. @property (nonatomic, readonly) const char *JSMethodName;
  26. @property (nonatomic, readonly) RCTFunctionType functionType;
  27. - (id)invokeWithBridge:(RCTBridge *)bridge
  28. module:(id)module
  29. arguments:(NSArray *)arguments;
  30. @end