Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

atom-package-config-observer

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atom-package-config-observer

A small library for observing a packages config in the Atom text editor

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

atom-package-config-observer

A small library for observing a packages config in the Atom text editor.

usage

ConfigObserver = require 'atom-package-config-observer'

class MyAtomPackage
  config: ...

  activate: ->
    # construct new ConfigObserver with your package name
    @configObserver = new ConfigObserver 'my-atom-package'
    # listen for global config changes
    @configObserver.observeGlobalConfig (config) =>
      @updateGlobalConfig config
    @configObserver.observeScopedConfig (config, editors, scopeName) =>
      # config keys not set for this scope are defaulted to global values
      # editors is an array of TextEditor instances associated with this scope
      # scopeName is a string identifying the scope (e.g. 'source.coffee')
      @updateScopedConfig config, editors, scopeName

  deactivate: ->
    @configObserver.dispose()

methods

observeGlobalConfig(callback)

Equivalent to atom.config.observe 'my-package-name', callback with the minor difference that the configuration object passed to the callback is a clone of the object returned by atom.config.observe.

observeScopedConfig(callback)

Observes TextEditor instances using atom.workspace.observeTextEditors to keep track of scopes to track. It then observes the config of each scope, disposing of the observer when no more TextEditors are associated with this scope. The callback has three arguments, see the usage section.

dispose()

Disposes of all registered observers.

configForScope(scopeName)

Returns a clone of the packages configuration object associated with the scope. When values are not set within the scope they are defaulted to the global configuration.

editorsForObservedScopes()

Returns an object with scopeNames as keys and an array of their associated TextEditors as value.

© Olmo Kramer, 2015
MIT License

FAQs

Package last updated on 21 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc