Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actions use Backbone methods instead of HTTP methods #8

Closed
neocotic opened this issue Sep 12, 2014 · 2 comments
Closed

Actions use Backbone methods instead of HTTP methods #8

neocotic opened this issue Sep 12, 2014 · 2 comments
Assignees
Milestone

Comments

@neocotic
Copy link
Owner

I want to try and see if I can remove the need to reverse the method lookup for the internal Backbone methodMap:

var methodMap = {
  'create': 'POST',
  'update': 'PUT',
  'patch':  'PATCH',
  'delete': 'DELETE',
  'read':   'GET'
};

This will allow this plugin to be more integrated with Backbone itself and thus not be bound strictly to HTTP. The API would be something like the following then:

var Book = Backbone.Model.extend({
  urlRoot: '/books',

  actions: {
    buy: {
      data: {
        referrer: 'Amazon'
      }
    },

    getPages: {
      url:    'pages',
      attrs:  'pageCount',
      method: 'read'
    }
  },

  initialize: function() {
    Backbone.Do(this);
  }
});

I will maintain the global defaultMethod but this may be changed to read which is not exactly the corresponding value for the existing default HTTP method (i.e. POST).

@neocotic neocotic added this to the 1.0.0 milestone Sep 12, 2014
@neocotic neocotic self-assigned this Sep 15, 2014
@neocotic
Copy link
Owner Author

Accidentally closed.

@neocotic
Copy link
Owner Author

This has been addressed by PR #14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant