未验证 提交 652a4b72 编写于 作者: O openharmony_ci 提交者: Gitee

!7258 modify continuation manager code example

Merge pull request !7258 from zhangmingxiang/0728
...@@ -97,6 +97,7 @@ register(options?: ContinuationExtraParams): Promise\<number>; ...@@ -97,6 +97,7 @@ register(options?: ContinuationExtraParams): Promise\<number>;
**示例:** **示例:**
```js ```js
let token = -1;
let continuationExtraParams = { let continuationExtraParams = {
deviceType: ["00E"] deviceType: ["00E"]
}; };
...@@ -157,6 +158,7 @@ on(type: "deviceConnect", token: number, callback: Callback\<Array\<Continuation ...@@ -157,6 +158,7 @@ on(type: "deviceConnect", token: number, callback: Callback\<Array\<Continuation
**示例:** **示例:**
```js ```js
let token = 1;
continuationManager.on("deviceConnect", token, (data) => { continuationManager.on("deviceConnect", token, (data) => {
console.info('onDeviceConnect len: ' + data.length); console.info('onDeviceConnect len: ' + data.length);
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
...@@ -186,6 +188,7 @@ on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>) ...@@ -186,6 +188,7 @@ on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>)
**示例:** **示例:**
```js ```js
let token = 1;
continuationManager.on("deviceDisconnect", token, (data) => { continuationManager.on("deviceDisconnect", token, (data) => {
console.info('onDeviceDisconnect len: ' + data.length); console.info('onDeviceDisconnect len: ' + data.length);
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
...@@ -213,6 +216,7 @@ off(type: "deviceConnect", token: number): void; ...@@ -213,6 +216,7 @@ off(type: "deviceConnect", token: number): void;
**示例:** **示例:**
```js ```js
let token = 1;
continuationManager.off("deviceConnect", token); continuationManager.off("deviceConnect", token);
``` ```
...@@ -234,6 +238,7 @@ off(type: "deviceDisconnect", token: number): void; ...@@ -234,6 +238,7 @@ off(type: "deviceDisconnect", token: number): void;
**示例:** **示例:**
```js ```js
let token = 1;
continuationManager.off("deviceDisconnect", token); continuationManager.off("deviceDisconnect", token);
``` ```
...@@ -255,6 +260,7 @@ startDeviceManager(token: number, callback: AsyncCallback\<void>): void; ...@@ -255,6 +260,7 @@ startDeviceManager(token: number, callback: AsyncCallback\<void>): void;
**示例:** **示例:**
```js ```js
let token = 1;
continuationManager.startDeviceManager(token, (err, data) => { continuationManager.startDeviceManager(token, (err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.error('startDeviceManager failed, cause: ' + JSON.stringify(err)); console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
...@@ -283,6 +289,7 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As ...@@ -283,6 +289,7 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As
**示例:** **示例:**
```js ```js
let token = 1;
let continuationExtraParams = { let continuationExtraParams = {
deviceType: ["00E"] deviceType: ["00E"]
}; };
...@@ -319,6 +326,7 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<v ...@@ -319,6 +326,7 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<v
**示例:** **示例:**
```js ```js
let token = 1;
let continuationExtraParams = { let continuationExtraParams = {
deviceType: ["00E"] deviceType: ["00E"]
}; };
...@@ -351,6 +359,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, ...@@ -351,6 +359,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState,
**示例:** **示例:**
```js ```js
let token = 1;
let deviceId: string = "test deviceId"; let deviceId: string = "test deviceId";
continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => { continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => {
if (err.code != 0) { if (err.code != 0) {
...@@ -386,6 +395,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState) ...@@ -386,6 +395,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState)
**示例:** **示例:**
```js ```js
let token = 1;
let deviceId: string = "test deviceId"; let deviceId: string = "test deviceId";
continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED) continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED)
.then((data) => { .then((data) => {
...@@ -414,6 +424,7 @@ unregister(token: number, callback: AsyncCallback\<void>): void; ...@@ -414,6 +424,7 @@ unregister(token: number, callback: AsyncCallback\<void>): void;
**示例:** **示例:**
```js ```js
let token = 1;
continuationManager.unregister(token, (err, data) => { continuationManager.unregister(token, (err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.error('unregister failed, cause: ' + JSON.stringify(err)); console.error('unregister failed, cause: ' + JSON.stringify(err));
...@@ -446,6 +457,7 @@ unregister(token: number): Promise\<void>; ...@@ -446,6 +457,7 @@ unregister(token: number): Promise\<void>;
**示例:** **示例:**
```js ```js
let token = 1;
continuationManager.unregister(token) continuationManager.unregister(token)
.then((data) => { .then((data) => {
console.info('unregister finished, ' + JSON.stringify(data)); console.info('unregister finished, ' + JSON.stringify(data));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册