Should I use a package or a node server?


#1

I would like to capture all keystrokes and file/dir operations (create/move/delete) in the editor and record them for later processing. I don’t want to slow the user of the editor down or make their experience a bad one. What is the best way to accomplish this?

Should I create a normal package and capture and record the events there or should I create a separate node server and handle them there? If the node server runs as a separate process I am thinking that would be preferred. Is there a good example of a node server running from atom?

Can a node server be notified when the editor/files system changes (I saw that VS Code has this feature)? Or, will I have to have a package that captures the events and sends them to the server? Any examples would be greatly appreciated.


#2

It depends on how much processing is needed. If you are only recording events then doing it in-process should work. I would be sure to use async writing though. Some changes can involve writing an entire large file.

I have done that in a package I never finished. It was pretty easy. I guess it is preferred in that if everyone did their work in-process it would add up.

I tried to talk the auto-complete-plus people into using a separate process because that involved a fair amount of computation. They didn’t. I don’t think people realize that all of node is restricted to one process which means one cpu core. Nowadays that is a big waste of cores.

Yes, but again it is pretty easy. You can get events on every single change. Then you just serialize them and send them over to the other process. I kept a mirror image of the text buffer in the other process and updated it in real time. I couldn’t detect any delays in the UI.


#3

Is there any chance that I can see your code? I’d really appreciate it.


#4

It would be embarrassing but what the heck. It was going to be a large project so a lot of it was for future use and won’t make sense. I also write really sloppy code until it works and then I refactor.

Damn, I found the repos mentioned in a discussion on 12/14 and it had the links. But now they are giving 404’s. Does anyone know how repos can disappear and more importantly how I get them back?

https://github.com/mark-hahn/autocomplete2
https://github.com/mark-hahn/autocomplete-generic

I’ll look through my old backups.


#5

I can’t find it right now, but somewhere there is an example of using an invisible BrowserWindow object to perform background processing.