Skip to content

Commit

Permalink
Merge pull request #1 from JeanLebrument/initialRelease
Browse files Browse the repository at this point in the history
Add index.js file and configure package.json
  • Loading branch information
Jean Lebrument authored and Jean Lebrument committed Oct 26, 2015
2 parents f5c73c8 + 1618381 commit 7398f9a
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
57 changes: 57 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "react-native-contacts-rx",
"version": "1.0.0",
"description": "react-native-contacts counterpart that include the support of RxJS.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/JeanLebrument/react-native-contacts-rx.git"
},
"keywords": [
"react-native",
"react-native-contacts",
"rx",
"rxjs"
],
"author": "Jean Lebrument",
"license": "MIT",
"bugs": {
"url": "https://github.com/JeanLebrument/react-native-contacts-rx/issues"
},
"homepage": "https://github.com/JeanLebrument/react-native-contacts-rx#readme"
}

0 comments on commit 7398f9a

Please # to comment.