Sha256: 6332652f44df483a6e26d3f586294e1938cd9c7100516df2cd6333ba1257116e

Contents?: true

Size: 747 Bytes

Versions: 3

Compression:

Stored size: 747 Bytes

Contents

class Api
  constructor: (options={})->
    @base = options.base
    @host = options.host
    @cache = {}

  get: (endpoint)->
    $.get("http://localhost:8080/stylish/#{endpoint}")

  browsePackages: (cb, bypass=false)->
    packages = @cache.packages

    if !bypass && packages
      cb(packages)
      return

    @get("models/browse/packages").then (r)=>
      @cache.packages = r
      cb(r)

  showPackage:(slug, cb, bypass=false)->
    @cache.packageDetails ||= {}
    existing = @cache.packageDetails[slug]

    if existing && !bypass
      cb(existing)
      return
    else
      @get("models/show/packages/#{slug}").then (r)=>
        @cache.packageDetails[slug] = r
        cb(r)

module.exports = apis = {}

apis.stylish = new Api()

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stylish-0.3.1 support/editor-app/development/src/apis/index.coffee
stylish-0.3.0 support/editor-app/development/src/apis/index.coffee
stylish-0.0.2 support/editor-app/development/src/apis/index.coffee