diff --git a/index.js b/index.js index 4f0e63c..eb6d83a 100644 --- a/index.js +++ b/index.js @@ -7,16 +7,19 @@ var ConnectionStatus = require('hoodie-client-connection-status') var Log = require('hoodie-client-log') var getState = require('./lib/get-state') -var id = require('./lib/id').id +var id = require('./lib/id') function Hoodie (options) { var state = getState(options) - var api = {} - api.id = id.bind(null, state) + var api = { + get id () { + return id.get(state) + } + } var CustomStore = Store.defaults({ remoteBaseUrl: '/hoodie/store/api' }) - var dbName = 'user/' + api.id() + var dbName = 'user/' + api.id api.store = new CustomStore(dbName) api.account = new Account({ url: '/hoodie/account/api' }) diff --git a/lib/id.js b/lib/id.js index c58b93c..131efc2 100644 --- a/lib/id.js +++ b/lib/id.js @@ -1,5 +1,5 @@ module.exports = { - id: id, + get: get, set: set, unset: unset } @@ -9,7 +9,7 @@ var config = require('humble-localstorage') var constants = require('./constants') var generateId = require('./utils/generate-id') -function id (state) { +function get (state) { if (!state.id) { set(state, generateId()) }