• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# MissionCallback
2
3The **MissionCallback** module defines the callbacks invoked after synchronization starts. These callbacks can be used as input parameters in [registerMissionListener](js-apis-distributedMissionManager.md#distributedmissionmanagerregistermissionlistener).
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
10
11| Name                                                | Template    | Readable| Writable| Description                              |
12| ---------------------------------------------------- | -------- | ---- | ---- | ---------------------------------- |
13| notifyMissionsChanged(deviceId: string)              | function | Yes  | No  | Callback used to notify the mission change event and return the device ID.        |
14| notifySnapshot(deviceId: string, mission: number)    | function | Yes  | No  | Callback used to notify the snapshot change event and return the device ID and mission ID.  |
15| notifyNetDisconnect(deviceId: string, state: number) | function | Yes  | No  | Callback used to notify the disconnection event and return the device ID and network status.|
16
17**Example**
18```ts
19import distributedMissionManager from '@ohos.distributedMissionManager';
20
21distributedMissionManager.registerMissionListener(
22    {
23        deviceId: '123456'
24    },
25    {
26        notifyMissionsChanged: (deviceId) => {
27            console.log(`notifyMissionsChanged deviceId: ${JSON.stringify(deviceId)}`);
28        },
29        notifySnapshot: (deviceId, mission) => {
30            console.log(`notifySnapshot deviceId: ${JSON.stringify(deviceId)}`);
31            console.log(`notifySnapshot mission: ${JSON.stringify(mission)}`);
32        },
33        notifyNetDisconnect: (deviceId, state) => {
34            console.log(`notifyNetDisconnect deviceId: ${JSON.stringify(deviceId)}`);
35            console.log(`notifyNetDisconnect state: ${JSON.stringify(state)}`);
36        }
37    });
38```
39