-
-
Notifications
You must be signed in to change notification settings - Fork 71
losing bound this in promise #63
Copy link
Copy link
Closed
Description
My code is
writeRaw(address, length, buffer) {
return pify(this.bus.i2cWrite).bind(this.bus)(address, length, buffer)
}
but when i2cWrite is called this is undefined. this is set when this runs
ret[key] = typeof property === 'function' && filter(key) ? processFn(property, options) : property;
but not inside the called processFn function
const processFn = (fn, options) => function (...args) {
// 'this' is not set here
<...>
}
What am I doing wrong?
P.S. Sorry I don't understand bind well enough to know what happens to a bound => function. I know => uses this from outside scope, but is that overridden by bind?
EDIT: I just realized that looking at this before and during processFn means nothing. I will try to debug this better but meanwhile, can someone look at my code above?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels