Osmose / advanced-open-file

Open files and folders in Atom easily.
https://atom.io/packages/advanced-open-file
Other
118 stars 20 forks source link

Add file created event #16

Closed Krzysztof-Cieslak closed 9 years ago

Krzysztof-Cieslak commented 9 years ago

Originally proposed in https://github.com/Trudko/advanced-new-file/pull/43

PR is adding just one line of code - emitting message ( with file path) to Atom emitter when file is created. Having it will make easier to react on file creation for other plugins, which can be very useful in some cases ( for example adding file name to project file used by some programming languages)

Osmose commented 9 years ago

Thanks for the PR! I'm totally down for adding the ability for being notified when we create a file.

I looked up some stuff on how Atom uses event emitters, and I don't think atom.emitter is meant to be used by packages because it's not documented as a public member. Also, the blog post about the API and the docs both recommend using an emitter internally and exposing a method like onDidCreateFile for people to use.

I think what we should do is add an emitter as a static property on the AdvancedFileView class and adding an onDidCreateFile static method for subscribing to the event. Then just use that emitter instead of atom.emitter. What do you think?

Krzysztof-Cieslak commented 9 years ago

Sounds good to me :) If You can, please, implement it yourself. I'm by no means a coffescritp expert and bit busy with some other stuff at the moment. Would appreciate it :)

But having this notification will be useful for one of the plugins I develop :)