Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Proposal: add a way for packages to communicate with one another #1136

@benogle

Description

@benogle

I added an API to the status-bar. Other packages that want to use the status bar have a bit of an awkward time getting a handle on the statusBar object. For reference see: atom/grammar-selector#2 Here's how it works now:

In the status bar, I do this:

statusBar = new StatusBarView()
atom.rootView.statusBar = statusBar

And in the package using status-bar:

# This is dumb:
createStatusEntry = ->
  view = new GrammarStatusView(atom.rootView.statusBar)
  atom.rootView.statusBar.appendLeft(view)

if atom.rootView.statusBar
  createStatusEntry()
else
  atom.packages.once 'activated', ->
    createStatusEntry()

I dont want to have every package author that wants to use something to the status bar to have to do this.

Proposal

I want to have some mechanism in one of the readily available objects (atom, rootView) for storage/retrieval of arbitrary objects. This is generally what I want to do:

In status-bar

statusBar = new StatusBarView()
atom.rootView.setChild('statusBar', statusBar)

In the package that uses status-bar

atom.rootView.getChild 'statusBar', (statusBar) ->
  view = new GrammarStatusView(atom.rootView.statusBar)
  atom.rootView.statusBar.appendLeft(view)

If statusBar is already there, it calls the callback, or it waits til statusBar is available.

I have no idea what to call these functions, and have no preference which object it should hang from.

Feedback, please.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions