Skip to content

Instantly share code, notes, and snippets.

@Daniel1984
Created February 24, 2016 11:54
Show Gist options
  • Save Daniel1984/31e50bd29981429d0861 to your computer and use it in GitHub Desktop.
Save Daniel1984/31e50bd29981429d0861 to your computer and use it in GitHub Desktop.
module = require('refactor/module')
class LayoutsResource
### @ngInject ###
constructor: ($resource, $q, API_HOST, TIME) ->
resource = $resource("#{API_HOST}/layouts/:id", { id: '@id' }, { update: { method: 'PUT' }})
resource::update = (success, failure) ->
resource.update({ id: @id }, @, success, failure)
resource.throttledQuery = _.throttle(->
queryDeferred = $q.defer()
resource.query().$promise.then((layouts) ->
queryDeferred.resolve(layouts)
)
queryDeferred.promise
, TIME.FIVE_MINUTES)
return resource
module.service('layoutsResource', LayoutsResource)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment