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

Comments

1 participant
@neocotic
Copy link
Owner

neocotic commented Sep 12, 2014

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 neocotic closed this Sep 16, 2014

@neocotic

This comment has been minimized.

Copy link
Owner

neocotic commented Sep 16, 2014

Accidentally closed.

@neocotic

This comment has been minimized.

Copy link
Owner

neocotic commented Sep 16, 2014

This has been addressed by PR #14.

@neocotic neocotic closed this Sep 16, 2014

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