RCTBridgeMethod.h 894 B

12345678910111213141516171819202122232425262728293031323334353637
  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. {
  16. switch (type) {
  17. case RCTFunctionTypeNormal:
  18. return "async";
  19. case RCTFunctionTypePromise:
  20. return "promise";
  21. case RCTFunctionTypeSync:
  22. return "sync";
  23. }
  24. };
  25. @protocol RCTBridgeMethod <NSObject>
  26. @property (nonatomic, readonly) const char *JSMethodName;
  27. @property (nonatomic, readonly) RCTFunctionType functionType;
  28. - (id)invokeWithBridge:(RCTBridge *)bridge module:(id)module arguments:(NSArray *)arguments;
  29. @end