Use of view calllbacks


I am trying to develop a plugin… So I have been trying to look at other plugins to get an idea of how this is done…

The basic structure I have seen in most is like

Atom.workspace. eacheditorview and register a callback that creates new class

The other is directly register the task using something like workspace. Command.task name…

So I wanted to know what is the use of using the callback… So will this create a new class for each editor…

So can anyone give some input on how to create a package???


Have you gone through the Creating a Package guide yet?


yes… i have read that post… But it does not go beyond the basic… also i have gone through the package tutorial too…


Can you be a little more clear in what you need help with other than “how to create a package” then?


The question is why use callbacks like atom.workspaceView.eachEditorView rather than do it like atom.workspaceView.command “asdf:toggle”, => @toggle()


Also with something like

atom.workspaceView.eachEditorView (editorView) =>       if editorView.attached and editorView.getPane()?         new BracketMatcherView(editorView)

does it not create a new class object for each editor ??? So what is the use ??


Perhaps the BracketMatcherView keeps track of state for each editorView? Whereas just calling a command doesn’t have any state to track?

Also, eachEditorView only gets called when a new editor view is created, to my understanding. Whereas a command is called when the command is triggered.

I really don’t think they’re equivalent at all.

As a side note, you might want to cut down on your use of repeated question marks. It conveys a sense of irritation or excitability, like you’re upset about the things you’re commenting on. It makes some people uncomfortable and reluctant to help.


Sorry about that. My intent was not that.

So unless i am doing something to track the happenings in each editor, i believe then there is no need to create a new class with the help of there callbacks… So i can just create a one class on activate and use the command trigger to implement the functionality.

Also are conflicting key shortcuts, transferred to multiple packages or does it just call only one of the package
Thanks for the assistance, @leedohm


If I’m understanding you correctly, the “Cascade Order” section of this page might help: