How to work addViewProvider with addBottomPanel


#1

In the API reference of addBottomPanel, the .item argument accepts

a model with a view registered via ViewRegistry::addViewProvider

and in the reference of addViewProvider, it requires contructor of a model, and returns only a Disposable. So how can I get the model that registered with the ViewRegistry?


#2

I believe you should work the other way around:

  1. Register a model constructor and a view constructor: viewProviderSubscription = atom.views.addViewProvider(MyModel, myViewFactory)
  2. Create a new model: myModel = new MyModel()
  3. Use the model with addBottomPanel: atom.workspace.addBottomPanel({item: myModel})

You can get the view associated with the model with myView = atom.views.getView(myModel) and on your package’s deactivation you can remove the view provider with viewProviderSubscription.dispose()