store.changes
takes a function as an argument. test
takes an object and its property as an argument:
store.changes(test(this, 'posts'))
function test (obj, prop) {
store.find().then(posts => {
obj[prop] = _.map(posts.rows, (post) => post.doc)
})
}
store.changes = (func) => {
return db.changes({
since: 'now',
live: true
}).on('change', func)
}
But for some reason store.changes
ins't recognizing test(this, 'posts')
as a function, it throws the following error:
Uncaught TypeError: listener must be a function
Why is this?
You're passing the result of a call, undefined
- not a function. I believe you are looking for
store.changes(() => test(this, 'posts'));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.