Skip to content

Commit

Permalink
Gaurd against value already being observ.
Browse files Browse the repository at this point in the history
  • Loading branch information
Raynos committed Nov 28, 2014
1 parent aa5f9a9 commit 8219f30
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ function ObservVarhash (hash, createValue) {
obs.delete = del.bind(obs)

for (key in hash) {
obs[key] = createValue(hash[key], key)
obs[key] = typeof hash[key] === 'function' ?
hash[key] : createValue(hash[key], key)

if (isFn(obs[key])) {
obs._removeListeners[key] = obs[key](watch(obs, key, currentTransaction))
Expand Down Expand Up @@ -59,7 +60,8 @@ function get (key) {
function put (createValue, key, val) {
checkKey(key)

var observ = createValue(val, key)
var observ = typeof observ === 'function' ?

This comment has been minimized.

Copy link
@DamonOehlman

DamonOehlman Dec 15, 2014

Contributor

Should this be typeof val === 'function' ?

This comment has been minimized.

Copy link
@Raynos

Raynos Dec 15, 2014

Author Contributor

yes it should! cc @nrw

createValue(val, key) : val
var state = extend(this())

state[key] = isFn(observ) ? observ() : observ
Expand Down Expand Up @@ -145,7 +147,9 @@ function checkKey (key) {
}

// identify deletes
function Tombstone () {}
function Tombstone () {

}

Tombstone.prototype.toJSON = nameTombstone
Tombstone.prototype.inspect = nameTombstone
Expand Down

0 comments on commit 8219f30

Please sign in to comment.