-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
57 lines (46 loc) · 1.42 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var Rx = require('rx');
var Contacts = require('react-native-contacts');
function _execAddressBookMethodWithParamsErrorData(func) {
return Rx.Observable.create(function(observer) {
func(function(error, data) {
if (error) {
observer.onError(error);
} else {
observer.onNext(data);
observer.onCompleted();
}
});
return null;
});
}
function _execAddressBookMethodWithParamError(contact, func) {
return Rx.Observable.create(function(observer) {
func(contact, function(error) {
if (error) {
observer.onError(error);
} else {
observer.onCompleted();
}
});
return null;
});
}
Contacts.rx_checkPermission = function() {
return _execAddressBookMethodWithParamsErrorData(Contacts.checkPermission);
};
Contacts.rx_requestPermission = function() {
return _execAddressBookMethodWithParamsErrorData(Contacts.requestPermission);
};
Contacts.rx_getAll = function() {
return _execAddressBookMethodWithParamsErrorData(Contacts.getAll);
};
Contacts.rx_addContact = function(contact) {
return _execAddressBookMethodWithParamError(contact, Contacts.addContact);
}
Contacts.rx_updateContact = function(contact) {
return _execAddressBookMethodWithParamError(contact, Contacts.updateContact);
}
Contacts.rx_deleteContact = function(contact) {
return _execAddressBookMethodWithParamError(contact, Contacts.deleteContact);
}
module.exports = Contacts;