Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone.rel

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone.rel - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

15

backbone.rel.js

@@ -84,3 +84,5 @@ /**

var collection = getOptions(this.self, 'belongsTo', this.key)
, result;
, eventBus = this.self.relEventBus
, result
, id;

@@ -94,3 +96,8 @@ if (!collection) {

} else {
result = collection.get(this.findBelongsToIdAttribute());
id = this.findBelongsToIdAttribute();
result = collection.get(id);
if (eventBus && !result) {
eventBus.trigger && eventBus.trigger('backbone-rel:missing', this.key, id);
}
}

@@ -204,5 +211,5 @@

_.extend(Backbone.Model.prototype, {rel: rel('Model'), relGet: relGet, relResult: relResult});
_.extend(Backbone.Collection.prototype, {rel: rel('Collection'), relGet: relGet, relResult: relResult});
_.extend(Backbone.Model.prototype, {rel: rel('Model'), relGet: relGet, relResult: relResult, relEventBus: null});
_.extend(Backbone.Collection.prototype, {rel: rel('Collection'), relGet: relGet, relResult: relResult, relEventBus: null});
}());
{
"name": "backbone.rel",
"description": "Lightweight relationship assistant for your backbone applications",
"version": "0.2.1",
"version": "0.2.2",
"author": "Pau ramon <masylum@gmail.com>",
"contributors": ["Maxim lolls <collsmaxim@gmail.com>"],
"contributors": ["Maxim Colls <collsmaxim@gmail.com>", "Saimon Moore <saimonmoore@gmail.com>"],
"keywords": ["backbone", "relations", "ender", "teambox"],

@@ -8,0 +8,0 @@ "repository": {"type": "git", "url": "git://github.com/masylum/Backbone.Rel.git"},

@@ -5,2 +5,3 @@ module.exports = (function () {

, Collections = {}
, EventBus = {}
, users, tasks, projects, comments;

@@ -11,2 +12,7 @@

_.extend(EventBus, Backbone.Events);
Backbone.Model.prototype.relEventBus = EventBus;
Backbone.Collection.prototype.relEventBus = EventBus;
Models.Task = Backbone.Model.extend({

@@ -133,3 +139,4 @@ belongsTo: function () {

, instance: instance
, EventBus: EventBus
};
})();

@@ -1,2 +0,2 @@

/*global it, describe, before, beforeEach*/
/*global it, describe, afterEach, before, beforeEach*/
var _ = require('underscore')

@@ -10,3 +10,5 @@ , data = require('./data')

describe('Rel', function () {
var users, projects, tasks;
var users
, projects
, tasks;

@@ -94,2 +96,38 @@ beforeEach(function () {

});
describe('event bus', function () {
var EventBus = data.EventBus
, events_triggered = [];
EventBus.bind('backbone-rel:missing', function (resource, id) {
events_triggered.push([resource, id]);
});
beforeEach(function () {
events_triggered = [];
});
describe('if a rel is missing', function () {
var user, missing_project;
beforeEach(function () {
missing_project = projects.get(0);
projects.remove(missing_project);
user = users.get(0);
});
afterEach(function () {
projects.add(missing_project);
});
it('triggers a "backbone-rel:missing" event on the event bus', function () {
user.rel('project');
assert.equal(events_triggered.length, 1);
assert.equal(events_triggered[0][0], 'project');
assert.equal(events_triggered[0][1], 0);
});
});
});
});

@@ -96,0 +134,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc