Skip to content
This repository has been archived by the owner on Sep 6, 2020. It is now read-only.

Commit

Permalink
Set event prefix in the http key
Browse files Browse the repository at this point in the history
  • Loading branch information
aarondfrancis committed Oct 12, 2017
1 parent fe7ff44 commit ab6fbe1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
18 changes: 8 additions & 10 deletions src/Defaults.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
var _ = require('lodash');

module.exports = {
// Names of any attributes that you want to be reactive
// The default model attributes. We'll initialize them all to
// null if there are no values for them. This is the starting
// point for the data that is sent to the server
attributes: [],

http: {
baseRoute: null,

eventPrefix: null,

// The _minimum_ amount of time that a successful ajax
// request should take. If the request fails it will
// return immediately, but if it's successful it won't
Expand Down Expand Up @@ -68,9 +72,7 @@ module.exports = {
index: {
method: 'GET',
route: '',
data: {
only: []
}
data: false
},
store: {
method: 'POST',
Expand All @@ -80,9 +82,7 @@ module.exports = {
method: 'GET',
route: '{id}',
apply: true,
data: {
only: []
}
data: false
},
update: {
method: 'PUT',
Expand All @@ -92,9 +92,7 @@ module.exports = {
destroy: {
method: 'DELETE',
route: '{id}',
data: {
only: []
}
data: false
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ module.exports = class Model {
}

emit(action, data) {
action = [this.settings.eventPrefix]
action = [this.settings.http.eventPrefix]
.concat(_.castArray(action))
.filter(_.identity)
.join('.');
Expand Down
6 changes: 3 additions & 3 deletions src/VueModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class VueModel {

// Set the name of the model as the Event Prefix,
// but only if there isn't a prefix set yet
definition = _.defaults(definition, {
eventPrefix: name
});
if (! _.get(definition, 'http.eventPrefix', false)) {
_.set(definition, 'http.eventPrefix', name);
}

this.registry[name] = definition;
}
Expand Down

0 comments on commit ab6fbe1

Please sign in to comment.