Skip to content

Commit

Permalink
fix getContext
Browse files Browse the repository at this point in the history
  • Loading branch information
mstdokumaci committed Mar 31, 2017
1 parent 9d5639b commit 4d6d072
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,23 @@ export default struct => {
}
}
},
getContext (key, context, isNew, hub) {
const retrieve = context(key)
if (isNew) {
hub.get('redis')
.load(key)
.then(loaded => {
let i = loaded.length
while (i--) {
retrieve.get(loaded[i].path, loaded[i].val, loaded[i].stamp)
}
})
.catch(error => {
hub.emit('error', error)
})
}
return retrieve
getContext (key, context, hub) {
return context(key)
.then(retrieve => {
hub.get('redis')
.load(key)
.then(loaded => {
let i = loaded.length
while (i--) {
retrieve.get(loaded[i].path, loaded[i].val, loaded[i].stamp)
}

return retrieve
})
.catch(error => {
hub.emit('error', error)
})
})
}
})

Expand Down

0 comments on commit 4d6d072

Please sign in to comment.