-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose external parameter to contact event
- Loading branch information
1 parent
f18f6eb
commit 0eaaae7
Showing
2 changed files
with
12 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,7 +254,7 @@ console.log(`Contact was ${updated ? 'updated' : 'not updated'}.`) | |
|
||
### `contacts.listener` | ||
|
||
This module exposes an `EventEmitter`, which can be used to listen to potential changes to the `CNContactStore`. When a contact is changed either with methods contained in this module, or manually by a user, the `contact-changed` event will be emitted. | ||
This module exposes an `EventEmitter`, which can be used to listen to potential changes to the `CNContactStore`. When a contact is changed either with methods contained in this module, or manually by a user, the `contact-changed` event will be emitted with one parameter `external`. This signifies whether or not the change to contact data originated outside the current app. | ||
|
||
Owing to the underlying architecture of this module, the listener must be manually managed; before use you must initialize it with `listener.setup()` and when you are finished listening for events you must remove it with `listener.remove()`. To check if a listener is currently active, use `listener.isListening()`. | ||
|
||
|
@@ -274,8 +274,8 @@ addNewContact({ | |
emailAddresses: ['[email protected]'], | ||
}) | ||
|
||
listener.once('contact-changed', () => { | ||
console.log('A contact was changed!') | ||
listener.once('contact-changed', (external) => { | ||
console.log(`A contact was changed ${external ? 'outside of' : 'within'} this app!`) | ||
listener.remove() | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters