Best practice to prevent selected event handlers from being invoked


#1

Hi all, I’m trying to develop a package that keeps tainted files as it is. So there shouldn’t be any prompt asking “Do you want to save the changes?”

I have figured out the chain of delegation. It starts from ipc.send("call-window-method", "close"), and the prompt window particularly is in pane class @promptToSaveItem.

Now, how should I achieve what I want to - add my cusom event handler for the window-close event, alongside other handlers. Disable not all event handlers but only the promptToSaveItem behaviour.

I can think of a few candidates that might NOT be good practices, like touching the pane class itself and replace its @promptToSaveItem method, which is a violation of https://en.wikipedia.org/wiki/Open/closed_principle.

I’m new to the community. Bear with me if I asked something obvious. Thanks in advance!


#2

Why do you want to circumvent the standard save behavior?


#3

Hi, thanks for your reply. I came from Sublime text editor. In Sublime it never prompts for saving. It sliently saves the state and resume when reopen. I’m trying to reproduce that behaviour for those who are used to Sublime.

See details here: https://github.com/boyangwang/the-tainted/blob/master/README.md


#4

Although Atom prompts for saving when explicitly closing tabs, it already autosaves the state of both buffers tied to files and in the latest beta autosaves untied buffers as well.

Relevant:


#5

Hi, thanks for the info. I installed beta: 1.4.0-beta1, and indeed the hahaviour is implemented