SkipLabs / skip

Skip is a framework for building reactive services
https://skiplabs.io
MIT License
152 stars 10 forks source link

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

Open mbouaziz opened 3 weeks ago

mbouaziz commented 3 weeks ago
          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_

bennostein commented 3 weeks ago

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