Open ventuno opened 6 years ago
Wow, cool! I love the idea of integrating this with bitbar.
I am not a fan of magic strings and I would not want the internals of this to be dependent on them. It inevitably leads to this: https://github.com/markis/watchman-processor/pull/133/commits/f7d93260e63a2f9bda57240d9f4fab08e498b2eb#diff-0ba683aead6f4617bf0950fcc8b0913dL72
I think all of this could have been done simply by building a different "terminal" class and just injecting it instead of rewiring all the internals to use events.
Thanks @markis how do you suggest I proceed? How would the alternative "terminal" class emit events to the outside world and how do developers inject it? Eventing/hooks seemed the most standard approach. I could expose event strings as constants and improved tests should protect from "magic" strings error.
@markis I spent some more time on this to use an enum
instead of just strings to trigger/listen to events. I tried to improve tests, but due the overall asynchronicity of the whole program it's a little difficult to do so without introducing flakiness. Let me know what you think.
@markis ping?
Sure @markis, just wanted to know if this had still a chance :-). Good luck with your sale!
Hey @markis any chance you could get to this? Maybe in the new year?
Most npm packages that run as a binary have also the ability to be imported in a project and run as a library. It would be great if
watchman-processor
worked the same way, so that developers could extend its functionality and create new UIs or integrate it with other tools if needed. Seewatchman-processor-tray-icon
[1] as an example that useswatchman-processor
as a library to create a bitbar plugin [2] and send notifications to the notification center (see also this better implementation of a tray icon using electron [3]).Changes summary: 1) Modify
WatchmanProcessor.ts
to emit node events instead of calling directlyTerminal.ts
; 1) Inbin/watchman-processor
listen to these events and call the correspondingTerminal.ts
methods; 1) Update tests accordingly.@markis, let me know if you like this idea, I think it would be a pretty powerful extension to this great package. More than happy to switch to more a appropriate architecture if needed, I kind of wanted to write down the code to convey the idea better.
[1] https://github.com/ventuno/watchman-processor-tray-icon/blob/f73d873463a3f682c649a1ca80b8b76cb2cbb11e/bitbar-plugin.js [2] https://github.com/matryer/bitbar#writing-plugins [3] https://github.com/ventuno/watchman-processor-tray-icon/pull/1