feat: allow null when subscribing notification (#33641)

* feat: allow null when subscribing notification

* docs: document null event
This commit is contained in:
Shelley Vohr 2022-04-13 22:02:33 +02:00 committed by GitHub
parent bfbba9dad6
commit b66667b843
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 15 deletions

View file

@ -84,7 +84,7 @@ that contains the user information dictionary sent along with the notification.
### `systemPreferences.subscribeNotification(event, callback)` _macOS_
* `event` string
* `event` string | null
* `callback` Function
* `event` string
* `userInfo` Record<string, unknown>
@ -109,9 +109,11 @@ example values of `event` are:
* `AppleColorPreferencesChangedNotification`
* `AppleShowScrollBarsSettingChanged`
If `event` is null, the `NSDistributedNotificationCenter` doesnt use it as criteria for delivery to the observer. See [docs](https://developer.apple.com/documentation/foundation/nsnotificationcenter/1411723-addobserverforname?language=objc) for more information.
### `systemPreferences.subscribeLocalNotification(event, callback)` _macOS_
* `event` string
* `event` string | null
* `callback` Function
* `event` string
* `userInfo` Record<string, unknown>
@ -122,9 +124,11 @@ Returns `number` - The ID of this subscription
Same as `subscribeNotification`, but uses `NSNotificationCenter` for local defaults.
This is necessary for events such as `NSUserDefaultsDidChangeNotification`.
If `event` is null, the `NSNotificationCenter` doesnt use it as criteria for delivery to the observer. See [docs](https://developer.apple.com/documentation/foundation/nsnotificationcenter/1411723-addobserverforname?language=objc) for more information.
### `systemPreferences.subscribeWorkspaceNotification(event, callback)` _macOS_
* `event` string
* `event` string | null
* `callback` Function
* `event` string
* `userInfo` Record<string, unknown>
@ -135,6 +139,8 @@ Returns `number` - The ID of this subscription
Same as `subscribeNotification`, but uses `NSWorkspace.sharedWorkspace.notificationCenter`.
This is necessary for events such as `NSWorkspaceDidActivateApplicationNotification`.
If `event` is null, the `NSWorkspaceNotificationCenter` doesnt use it as criteria for delivery to the observer. See [docs](https://developer.apple.com/documentation/foundation/nsnotificationcenter/1411723-addobserverforname?language=objc) for more information.
### `systemPreferences.unsubscribeNotification(id)` _macOS_
* `id` Integer