Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Update api with a single object
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnocentini committed Dec 5, 2016
1 parent 8ddc435 commit 0ac61a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
9 changes: 3 additions & 6 deletions ReactNativeCouchbaseLiteExample/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import {
ListView,
} from 'react-native';

import {
rncblite,
ReactCBLite
} from 'react-native-couchbase-lite';
import Couchbase from 'react-native-couchbase-lite';

import List from './components/list';

Expand All @@ -35,8 +32,8 @@ export default class Root extends Component {
}

componentDidMount() {
rncblite(manager => {
ReactCBLite.installPrebuiltDatabase(DB_NAME);
Couchbase.initRESTClient(manager => {
Couchbase.installPrebuiltDatabase(DB_NAME);
this.setState({manager: manager});
});
}
Expand Down
26 changes: 12 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import {NativeModules} from "react-native";
import Swagger from "swagger-client";
import spec from "./spec.json";
var {NativeModules} = require('react-native');
var Couchbase = NativeModules.ReactCBLite;

const ReactCBLite = NativeModules.ReactCBLite;
var Swagger = require('swagger-client');
var spec = require('./spec.json');

let manager, callback;

ReactCBLite.init(url => {
var manager, callback;
Couchbase.init(url => {
spec.host = url.split('/')[2];

new Swagger({spec: spec, usePromise: true})
new Swagger({ spec: spec, usePromise: true })
.then(client => {
manager = client;
if (typeof callback == 'function') {
if(typeof callback == 'function'){
callback(manager);
}
});
});

const rncblite = function (cb) {
if (typeof manager !== 'undefined') {
cb(manager); // If manager is already defined then don't wait
Couchbase.initRESTClient = function(cb){
if(typeof foo != 'undefined'){
cb(manager); // If manager is already define, don't wait.
} else {
callback = cb;
}
};

module.exports = {rncblite, ReactCBLite};
module.exports = Couchbase;

1 comment on commit 0ac61a4

@npomfret
Copy link
Contributor

@npomfret npomfret commented on 0ac61a4 Dec 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi james - you backed out my change here, was the intentional? I think

if(typeof foo != 'undefined'){

should read

if (typeof manager !== 'undefined') {

[edit] - ah looks like all my changes have gone.

Please sign in to comment.