New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flux-crud-store

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flux-crud-store - npm Package Compare versions

Comparing version 0.0.1 to 0.0.3

.jshintignore

30

lib/crud_store_actions.js
'use strict';
var assign = require('object-assign');
var extend = require('backbone').Collection.extend;

@@ -21,3 +20,3 @@ var _ = require('underscore');

assign(CrudStoreActions.prototype, {
_(CrudStoreActions.prototype).extend({
create: function (data) {

@@ -55,7 +54,11 @@ var model = new this._collection.model(data);

fetchAll: function () {
this._fetchingAll = true;
if (!this._collection.url) {
throw 'fetchAll action requires \'url\' to be set on collection class!';
}
this._isFetchingAll = true;
this._collection.fetch({
silent: true,
success: function () {
this._fetchingAll = false;
this._isFetchingAll = false;
}.bind(this)

@@ -65,2 +68,21 @@ });

fetch: function (id) {
if (!this._collection.url) {
throw 'fetch action requires \'url\' to be set on collection class!';
}
var model = this._collection.get(id);
if (!model) {
model = new this._collection.model({ id: id });
this._collection.add(model);
}
this._isFetching[id] = true;
model.fetch({
success: function () {
this._isFetching[id] = false;
}.bind(this)
});
},
save: function (id) {

@@ -67,0 +89,0 @@ var model = this._collection.get(id);

@@ -5,3 +5,2 @@ 'use strict';

var OrderedMap = require('immutable').OrderedMap;
var assign = require('object-assign');
var extend = Collection.extend;

@@ -16,4 +15,7 @@ var _ = require('underscore');

CrudStore.extend = extend;
CrudStore.instance = function () {
return new this();
};
assign(CrudStore.prototype, {
_(CrudStore.prototype).extend({
collection: Collection,

@@ -26,4 +28,10 @@

if (!this.collection) {
throw 'collection must be set on the Store class';
}
this._collection = new this.collection();
this._viewModels = new OrderedMap();
this._isFetchingAll = false;
this._isFetching = {};
},

@@ -48,3 +56,3 @@

getAll: function () {
if (this._fetchingAll) {
if (this._isFetchingAll) {
return this._loadingResponse;

@@ -67,2 +75,6 @@ }

get: function (id) {
if (this._isFetching[id]) {
return this._loadingResponse;
}
var model = this._collection.get(id);

@@ -69,0 +81,0 @@

4

package.json

@@ -6,3 +6,3 @@ {

"author": "Holman Gao <holman@golmansax.com>",
"version": "0.0.1",
"version": "0.0.3",
"main": "lib/index.js",

@@ -23,2 +23,3 @@ "repository": {

"devDependencies": {
"browserify": "latest",
"chai": "1.9.2",

@@ -38,3 +39,2 @@ "dirty-chai": "latest",

"immutable": "latest",
"object-assign": "latest",
"underscore": "latest"

@@ -41,0 +41,0 @@ },

@@ -11,5 +11,18 @@ # Flux CRUD Store

## Installation
### Node
```bash
# Node
npm install flux-crud-store --save
```
```js
var CrudStore = require('flux-crud-store').Store;
var CrudActions = require('flux-crud-store').Actions;
```
### Bower
```bash
bower install flux-crud-store
```
```js
// Assuming dist/flux_crud_store.js has been included without CommonJS or RequireJS
var CrudStore = FluxCrudStore.Store;
var CrudActions = FluxCrudStore.Actions;
```

Sorry, the diff of this file is not supported yet

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