stampit-org / stamp

Stamps - better OOP model
https://stampit.js.org
MIT License
25 stars 3 forks source link

Please explain this use of `bind()` without any argument at the end of `@stamp/it` #76

Closed PopGoesTheWza closed 4 years ago

PopGoesTheWza commented 4 years ago

https://github.com/stampit-org/stamp/blob/90558ea3d3c49d7fe0e06c84be0f03b57e9627c4/packages/it/index.js#L100

koresar commented 4 years ago

I don't exactly recall. But I think tests fail without it. Do they?

koresar commented 4 years ago

Oh. I remember now. The "compose" function should compose "this" context into the stamp it creates. The binding makes sure that "this === undefined".

PopGoesTheWza commented 4 years ago

So somefunction.bind() is similar to somefunction.bind(undefined) I believe?

And we are adding a wrapping around stampit.compose since there is no other way to retrieve the unbound function, correct?

koresar commented 4 years ago

Correct

On Sun., 5 Jan. 2020, 21:13 PopGoesTheWza, notifications@github.com wrote:

So somefunction.bind() is similar to somefunction.bind(undefined) I believe?

And we are adding a wrapping around stampit.compose since there is no other way to retrieve the unbound function, correct?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/stampit-org/stamp/issues/76?email_source=notifications&email_token=AAMMEL3RZHYJ3K6TFP57CZTQ4GXFLA5CNFSM4KCZNHJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIDTBJI#issuecomment-570896549, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMMELZ62YEGQSYMN3X37WDQ4GXFLANCNFSM4KCZNHJA .