• 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
21let missionDeviceInfo = {
22    deviceId: '123456'
23};
24let missionCallback = {
25    notifyMissionsChanged: function (deviceId) {
26        console.log('notifyMissionsChanged deviceId: ' + JSON.stringify(deviceId));
27    },
28    notifySnapshot: function (deviceId, mission) {
29        console.log('notifySnapshot deviceId: ' + JSON.stringify(deviceId));
30        console.log('notifySnapshot mission: ' + JSON.stringify(mission));
31    },
32    notifyNetDisconnect: function (deviceId, state) {
33        console.log('notifyNetDisconnect deviceId: ' + JSON.stringify(deviceId));
34        console.log('notifyNetDisconnect state: ' + JSON.stringify(state));
35    }
36};
37distributedMissionManager.registerMissionListener(missionDeviceInfo, missionCallback);
38```
39