Fusion icon indicating copy to clipboard operation
Fusion copied to clipboard

`Fusion.cleanup` should be renamed

Open Barocena opened this issue 3 years ago • 10 comments

Currently, Fusion api have cleanup and Cleanup for different usecases.

it is confusing to remember which one is which and easy to assume both functions are same

so I suggest renaming the cleanup to clean, which also sounds better when the other option is doNothing

Barocena avatar Feb 15 '23 22:02 Barocena

A wild idea: it looks like ForKeys, ForValues and ForPairs accept a callable object, not just a function. So, it should be possible to add a __call metamethod to the Cleanup object and the user can simply pass it in, as-is.

u-train avatar Feb 15 '23 23:02 u-train

A wild idea: it looks like ForKeys, ForValues and ForPairs accept a callable object, not just a function. So, it should be possible to add a __call metamethod to the Cleanup object and the user can simply pass it in, as-is.

I don't think Elttob wants to use metatables for clarity, however it sounds like a good idea!

krypt102 avatar Feb 16 '23 01:02 krypt102

I veto any metatables, ever™.

(only half joking there. stick to simple primitives! metatables confuse junior devs)

dphfox avatar Feb 23 '23 23:02 dphfox

By the way, I agree with this premise. Feel free to bikeshed names here.

I only named it this way because I cared more about having the thing implemented rather than making the prettiest variables :)

dphfox avatar Feb 23 '23 23:02 dphfox

I would prefer that Cleanup gets renamed to OnDestroy. OnDestroy better matches the convention of the other event listener keys, and it more aptly describes the fact that it will call your destructor functions. I think cleanup is an acceptable name as it is, but doCleaning might be more consistent? Not sure if it's worth changing that one.

boatbomber avatar Feb 26 '23 01:02 boatbomber

Call it doCleanup.

P3tray avatar May 07 '23 22:05 P3tray

Call it doCleanup.

I like that idea. It matches the doNothing name and also concisely indicates it's an action.

I would prefer that Cleanup gets renamed to OnDestroy. OnDestroy better matches the convention of the other event listener keys, and it more aptly describes the fact that it will call your destructor functions. I think cleanup is an acceptable name as it is, but doCleaning might be more consistent? Not sure if it's worth changing that one.

This is also a good point. I think it's worth changing both to help keep some good distance between them.

dphfox avatar May 21 '23 01:05 dphfox

metatables confuse ~~junior~~ devs

:)

Late to the party here but was also having the same issue, it can be confusing.

I prefer doCleanup for performing the action, as it is easy to remember, and OnDestroy makes more sense than Cleanup

plasma-node avatar Jul 18 '23 05:07 plasma-node

We'll rename it to doCleanup in v0.3. Thanks for the feedback everyone.

dphfox avatar Aug 22 '23 20:08 dphfox

We'll rename it to doCleanup in v0.3. Thanks for the feedback everyone.

Can't wait to be in the change log for suggesting a name.

P3tray avatar Aug 23 '23 15:08 P3tray