Skip to content

Commit 64ad557

Browse files
author
lemon
committed
update the doc ,add the description about the retry mechanism feature
1 parent 2c0a9ae commit 64ad557

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# UPDATES
66

7+
* 2017/04/09 adding the retry mechanism of injecting bridge
8+
79
* 2017/04/08 invoke Java synchornized from Javascript is now enable in `feature/sync`
810

911
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,6 +15,16 @@
1315

1416
# FEATURES
1517

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+
1628
#### ✔️ Register Handler with APT
1729

1830
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
92104

93105
# <a name="README_CN">功能</a>
94106

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
96118

97119
支持使用apt技术,完成注册handler的功能,步骤如下:
98120

0 commit comments

Comments
 (0)