Skip to content

Commit

Permalink
feat: Converting hoodie.id() to hoodie.id getter
Browse files Browse the repository at this point in the history
BREAKING CHANGE: hoodie.id() was a method to return the id, but we are
converting it to a getter (see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get)

fixes #11
  • Loading branch information
nathanstilwell committed Nov 21, 2015
1 parent 5f2787c commit b315a40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
Expand Down
4 changes: 2 additions & 2 deletions lib/id.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
id: id,
get: get,
set: set,
unset: unset
}
Expand All @@ -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())
}
Expand Down

0 comments on commit b315a40

Please sign in to comment.