|
4 | 4 |
|
5 | 5 | # UPDATES
|
6 | 6 |
|
| 7 | +* 2017/04/09 adding the retry mechanism of injecting bridge |
| 8 | + |
7 | 9 | * 2017/04/08 invoke Java synchornized from Javascript is now enable in `feature/sync`
|
8 | 10 |
|
9 | 11 | Now the `BridgeHandler` has two function to be invoked from JavaScript.If the JavaScirpt invoke Java with a callback function,the Java method will be invoked Synchronizlly ,otherwise the Java method will be invoked asynchronous.
|
|
13 | 15 |
|
14 | 16 | # FEATURES
|
15 | 17 |
|
| 18 | +#### ✔️Inject Bridge with retry mechanism |
| 19 | + |
| 20 | +Now when EasyBridge try to inject a comunication bridge into the page,it will retry at most five times to make sure that the bridge is injected successfully .It works as below: |
| 21 | + |
| 22 | +1. `EasyBridgeWebView` will register a handler name "injectFinished" default |
| 23 | +2. when the bridge injected finish,it will invoke the handler in step one, and set the injected status to be true |
| 24 | +3. When injecting a bridge ,it will start a task `InjectBridgeTask`,it will try to inject the bridge every 300ms at most 5 times,if the injected status is false |
| 25 | + |
| 26 | +**because of the single thread mechanism in JavaScrpt,we will make sure that the bridge will not be injected twice in the same page** |
| 27 | + |
16 | 28 | #### ✔️ Register Handler with APT
|
17 | 29 |
|
18 | 30 | Now you can register Handlers using the APT tech.Follow the steps:
|
@@ -92,7 +104,17 @@ You can set your policy according to the current page's url and the parameters y
|
92 | 104 |
|
93 | 105 | # <a name="README_CN">功能</a>
|
94 | 106 |
|
95 |
| -#### ✔️ 使用apt技术注册handler |
| 107 | +#### ✔️ 注入jsbridge添加重试机制 |
| 108 | + |
| 109 | +现在当我们往页面中注入bridge的时候,具备了重试机制。EasyBridge最多会尝试5次重试,尽可能的确保bridge被注入成功。重试机制的工作流程如下: |
| 110 | + |
| 111 | +1. 当我们初始化`EasyBridgeWebView`的时候,它会默认的注册一个名称为`injectFinished`的handler,用以监听bridge注入成功,并设置标志值 |
| 112 | +2. 在bridge注入成功之后,会调用上面注册的那个handler,通知native,bridge已经注入成功了; |
| 113 | +3. 在注入bridge的时候,会启动一个`InjectBridgeTask`的任务,在注入成功的标志状态值`isInjected`为false的情况下,它会每隔300ms发起一次注入bridge的操作(最多重试5次) |
| 114 | + |
| 115 | +**因为JavaScript是单线程的,所以我们能确保同一个页面不会出现重复注入bridge的情况** |
| 116 | + |
| 117 | +#### 使用apt技术注册handler |
96 | 118 |
|
97 | 119 | 支持使用apt技术,完成注册handler的功能,步骤如下:
|
98 | 120 |
|
|
0 commit comments