FullScreenShenanigans / TimeHandlr

A flexible, pausable alternative to setTimeout and setInterval for GameStartr Things.
MIT License
1 stars 0 forks source link

Add in scope-bound equivalents of addEvent, addEventInterval #6

Open JoshuaKGoldberg opened 8 years ago

JoshuaKGoldberg commented 8 years ago

Perhaps addEventBound and addEventIntervalBound?

See https://github.com/Microsoft/TypeScript/pull/6739 for guidance on implementation.

This will be useful for GameStartr projects: now that they're moving to not taking in the GameStartr instance as a first parameter, there will be some overhead in always having to pass () => scopes.

Old:

FSP.TimeHandler.addEvent(FSP.killNormal, 7, thing);

Current (either):

FSP.TimeHandler.addEvent(FSP.killNormal.bind(FSP), 7, thing);
FSP.TimeHandler.addEvent((thing: IThing): void => FSP.killNormal(thing), 7, thing);

With this:

FSP.TimeHandler.addEventBound(FSP.killNormal, FSP, 7, thing);
JoshuaKGoldberg commented 8 years ago

See the discussion at https://github.com/palantir/tslint/issues/1449#issuecomment-238070857.