skdb icon indicating copy to clipboard operation
skdb copied to clipboard

Style/ts: replace `(args) => obj.method(args)` with `obj.method.bind(obj)`

Open mbouaziz opened this issue 1 year ago • 1 comments

          In that case let's open an issue with a reminder to use that style across the board (there are instances of the lambda variant in the skipruntime client or server).

Originally posted by @beauby in https://github.com/SkipLabs/skdb/pull/345#discussion_r1781140562

mbouaziz avatar Sep 30 '24 13:09 mbouaziz

With (arg1, arg2) => obj.method(arg1, arg2), I want to simplify to just obj.method and then it fails... so obj.method.bind(obj), although ugly, makes it explicit

I've had the same impulse to eta-reduce but didn't know about bind to do so safely! Seems insane that that's not the default binding behaviour for JS methods, but so it goes

bennostein avatar Sep 30 '24 14:09 bennostein