WXModuleProtocol.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. #import <UIKit/UIKit.h>
  20. #import "WXDefine.h"
  21. #import "WXSDKInstance.h"
  22. #define MSG_SUCCESS @"WX_SUCCESS"
  23. #define MSG_NO_HANDLER @"WX_NO_HANDLER"
  24. #define MSG_NO_PERMIT @"WX_NO_PERMISSION"
  25. #define MSG_FAILED @"WX_FAILED"
  26. #define MSG_PARAM_ERR @"WX_PARAM_ERR"
  27. #define MSG_EXP @"WX_EXCEPTION"
  28. @protocol WXModuleProtocol <NSObject>
  29. /**
  30. * @abstract the module callback , result can be string or dictionary.
  31. * @discussion callback data to js, the id of callback function will be removed to save memory.
  32. */
  33. typedef void (^WXModuleCallback)(id result);
  34. //DEPRECATED_MSG_ATTRIBUTE("use WXModuleKeepAliveCallback, you can specify keep the callback or not, if keeped, it can be called multi times, or it will be removed after called.")
  35. /**
  36. * @abstract the module callback , result can be string or dictionary.
  37. * @discussion callback data to js, you can specify the keepAlive parameter to keep callback function id keepalive or not. If the keepAlive is true, it won't be removed until instance destroyed, so you can call it repetitious.
  38. */
  39. typedef void (^WXModuleKeepAliveCallback)(id result, BOOL keepAlive);
  40. #define WX_EXPORT_MODULE(module)
  41. @optional
  42. /**
  43. * @abstract returns the execute queue for the module
  44. *
  45. * @return dispatch queue that module's methods will be invoked on
  46. *
  47. * @discussion the implementation is optional. Implement it if you want to execute module actions in the special queue.
  48. * Default dispatch queue will be the main queue.
  49. *
  50. */
  51. - (dispatch_queue_t)targetExecuteQueue;
  52. /**
  53. * @abstract returns the execute thread for the module
  54. *
  55. * @return thread that module's methods will be invoked on
  56. *
  57. * @discussion the implementation is optional. If you want to execute module actions in the special thread, you can create a new one.
  58. * If `targetExecuteQueue` is implemented, the queue returned will be respected first.
  59. * Default is the main thread.
  60. *
  61. */
  62. - (NSThread *)targetExecuteThread;
  63. /**
  64. * @abstract the instance bind to this module. It helps you to get many useful properties related to the instance.
  65. */
  66. @property (nonatomic, weak) WXSDKInstance *weexInstance;
  67. @end