How to use the schmackbone.Collection function in schmackbone

To help you get started, we’ve selected a few schmackbone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SiftScience / resourcerer / test / with-resources.jsx View on Github external
it('does not fetch resources that are passed in via props', () => {
    resources = renderWithResources({
      userModel: new Schmackbone.Model(),
      analystsCollection: new Schmackbone.Collection(),
      decisionsCollection: new Schmackbone.Collection()
    });

    expect(requestSpy).not.toHaveBeenCalled();

    ReactDOM.unmountComponentAtNode(jasmineNode);

    // the models passed down are not fetched
    resources = renderWithResources({
      userModel: new Schmackbone.Model(),
      decisionsCollection: new Schmackbone.Collection()
    });

    expect(requestSpy.calls.count()).toEqual(1);
    expect(requestSpy.calls.mostRecent().args[0]).toEqual('analysts');
  });
github SiftScience / resourcerer / test / with-resources.jsx View on Github external
it('does not fetch resources that are passed in via props', () => {
    resources = renderWithResources({
      userModel: new Schmackbone.Model(),
      analystsCollection: new Schmackbone.Collection(),
      decisionsCollection: new Schmackbone.Collection()
    });

    expect(requestSpy).not.toHaveBeenCalled();

    ReactDOM.unmountComponentAtNode(jasmineNode);

    // the models passed down are not fetched
    resources = renderWithResources({
      userModel: new Schmackbone.Model(),
      decisionsCollection: new Schmackbone.Collection()
    });

    expect(requestSpy.calls.count()).toEqual(1);
    expect(requestSpy.calls.mostRecent().args[0]).toEqual('analysts');
  });
github SiftScience / resourcerer / lib / index.js View on Github external
import _ from 'underscore';
import _prefetch from './prefetch';
import ErrorBoundary from './error-boundary';
import {LoadingStates} from './constants';
import ModelCache from './model-cache';
import React from 'react';
import request from './request';
import Schmackbone from 'schmackbone';
import schmackboneMixin from './schmackbone-mixin';

const SPREAD_PROVIDES_CHAR = '_';

// pending and errored resources are not cached, but instead of passing down an
// undefined prop, we pass down empty models for greater defense in client code
export const EMPTY_MODEL = Object.freeze(new Schmackbone.Model());
export const EMPTY_COLLECTION = Object.freeze(new Schmackbone.Collection());

// ensure that no withResources client can modify empty models' data
Object.freeze(EMPTY_MODEL.attributes);
Object.freeze(EMPTY_COLLECTION.models);

/**
 * This HOC is a light wrapper around the DataCarrier component for setting
 * state that should trigger resource updates. Some things won't need this, ie
 * a url update that passes its query params down as props[queryParamsPropName].
 * But it provides a setResourceState method to wrap any necessary state that
 * may cause a resource update in DataCarrier's componentWillReceiveProps.
 */
const resourceState = (Component) =>
  class ResourceStateWrapper extends React.Component {
    constructor() {
      super();
github SiftScience / resourcerer / test / schmackbone-mixin.js View on Github external
describe('SchmackboneMixin', () => {
  var dummyComponent,
      model1 = new Schmackbone.Model(),
      model2 = new Schmackbone.Collection(),
      model3 = new Schmackbone.Model(),
      forceUpdateSpy;

  beforeEach(() => {
    dummyComponent = new (schmackboneMixin(class Component extends React.Component {
      constructor() {
        super();

        this.model1 = model1;
        this.model2 = model2;
      }

      _getBackboneModels() {
        return [
          model1,
          model2,

schmackbone

jQuery-less, Promise-interfaced models based on BackboneJS

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular schmackbone functions