WXPrerenderManager.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 <Foundation/Foundation.h>
  20. #import "WXModuleProtocol.h"
  21. @class WXModuleMethod;
  22. @interface WXPrerenderManager : NSObject
  23. - (instancetype) init NS_UNAVAILABLE;
  24. /**
  25. * @abstract add prerender task
  26. *
  27. * @param url The prerender url string
  28. *
  29. * @param instanceId The instanceId that its instance add prerender task
  30. *
  31. * @param callback the module method callback
  32. *
  33. **/
  34. + (void) addTask:(NSString *) url instanceId:(NSString *)instanceId callback:(WXModuleKeepAliveCallback)callback;
  35. /**
  36. * @abstract add prerender task
  37. *
  38. * @param url The prerender url string
  39. *
  40. * @param callback the module method callback
  41. *
  42. **/
  43. + (void) addGlobalTask:(NSString *) url callback:(WXModuleKeepAliveCallback)callback;
  44. /**
  45. * @abstract Returns true if url is exist in task .
  46. *
  47. **/
  48. + (BOOL) isTaskExist:(NSString *)url;
  49. /**
  50. * @abstract Returns true if task ready.
  51. *
  52. **/
  53. + (BOOL)isTaskReady:(NSString *)url;
  54. /**
  55. * @abstract Returns key from url .
  56. *
  57. **/
  58. + (NSString *)getTaskKeyFromUrl:(NSString *)url;
  59. /**
  60. * @abstract Returns error if url is prerender fail .
  61. *
  62. **/
  63. + (NSError *)errorFromUrl:(NSString *)url;
  64. /**
  65. * @abstract excute render from prerender cache .
  66. * @discussion this method should be excuted after oncreat and onfail block created
  67. *
  68. **/
  69. + (void) renderFromCache:(NSString *)url;
  70. /**
  71. * @abstract Returns prerender root view .
  72. *
  73. **/
  74. + (UIView *)viewFromUrl:(NSString *)url;
  75. /**
  76. * @abstract Returns prerender instance .
  77. *
  78. **/
  79. + (id)instanceFromUrl:(NSString *)url;
  80. /**
  81. * @abstract Remove prerender task by url .
  82. *
  83. **/
  84. + (void)removePrerenderTaskforUrl:(NSString *)url;
  85. /**
  86. * @abstract store prerender module task by url .
  87. *
  88. **/
  89. + (void)storePrerenderModuleTasks:(WXModuleMethod *)prerenderModuleTask forUrl:(NSString *)url;
  90. /**
  91. * @abstract destroy task , it will destroy instance also.
  92. *
  93. **/
  94. + (void)destroyTask:(NSString *)parentInstanceId;
  95. @end