Skip to content
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

Pulling changes back to other repo #3

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"lerna": "2.0.0-beta.26",
"version": "3.3.2"
"version": "3.4.1"
}
12 changes: 6 additions & 6 deletions packages/tectonic-superagent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gs-tectonic-superagent",
"version": "3.3.2",
"version": "3.4.1",
"description": "A tectonic driver for remote AJAX calls using Superagent with callbacks",
"main": "transpiled/index.js",
"scripts": {
Expand Down Expand Up @@ -32,12 +32,12 @@
},
"homepage": "https://github.com/gsbhalsted/tectonic-superagent#readme",
"dependencies": {
"superagent": "^1.8.3"
"superagent": "^1.8.5"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.6.5",
"babel-core": "^6.7.4",
"babel-preset-es2015": "^6.6.0"
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1"
}
}
46 changes: 23 additions & 23 deletions packages/tectonic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gs-tectonic",
"version": "3.3.1",
"version": "3.4.1",
"description": "Declarative data loading for React",
"main": "transpiled/index.js",
"scripts": {
Expand Down Expand Up @@ -28,36 +28,36 @@
},
"homepage": "https://github.com/gsbhalsted/tectonic#readme",
"devDependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.6.5",
"babel-core": "^6.5.2",
"babel-eslint": "^7.0.0",
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^7.2.3",
"babel-plugin-syntax-decorators": "^6.13.0",
"babel-plugin-syntax-flow": "^6.13.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-flow-strip-types": "^6.14.0",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"chai": "^3.4.1",
"eslint": "^3.7.1",
"babel-plugin-syntax-flow": "^6.18.0",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"chai": "^3.5.0",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^12.0.0",
"eslint-plugin-flowtype": "^2.20.0",
"eslint-plugin-flowtype": "^2.50.3",
"eslint-plugin-import": "^1.16.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.3.0",
"eslint-plugin-react": "^6.10.3",
"flow-bin": "^0.33.0",
"jsdom": "^7.2.2",
"mocha": "^2.3.4",
"react-addons-test-utils": "^0.14.7",
"redux": "^3.3.1",
"sinon": "^1.17.3"
"mocha": "^2.5.3",
"react-addons-test-utils": "^0.14.8",
"redux": "^3.7.2",
"sinon": "^1.17.7"
},
"dependencies": {
"debug": "^2.2.0",
"debug": "^2.6.9",
"deep-equal": "^1.0.1",
"immutable": "^3.8.1",
"react": "^0.14.7",
"react-redux": "^4.4.0"
"immutable": "^3.8.2",
"react": "^0.14.9",
"react-redux": "^4.4.9"
}
}
3 changes: 3 additions & 0 deletions packages/tectonic/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
export default from './decorator';
export Model from './model';
export Manager from './manager';
export Query from './query';

// Export the <Loader /> wrapper component
export Loader from './component';
export reducer from './reducer';

// Resolvers
export BaseResolver from './resolver/baseResolver.js';
export Status from './status/status.js';
Expand Down
4 changes: 4 additions & 0 deletions packages/tectonic/src/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ export default class Model {
return this.record.toJS();
}

equals(other) {
return other && other.record && this.record.equals(other.record);
}

/*
set(key: string, value: any): Model {
const newRecord = this.record.set(key, value);
Expand Down
8 changes: 8 additions & 0 deletions packages/tectonic/src/query/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ export default class Query {
this.callback = callback;
this.children = [];

// Overload params with a _skipCache
if (this.params._skipCache) {
this._skipCache = true;
} else {
this._skipCache = false;
}
delete this.params._skipCache;

// To create query trees we need to iterate through each param and see if
// the value is a function; if it is we assume this was created via
// PropInspector and calculates this Query's parent query.
Expand Down
5 changes: 5 additions & 0 deletions packages/tectonic/src/resolver/baseResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ export default class BaseResolver {
//
// This returns a boolean indicating whether we can short circuit
skipFromCache(query: Query, hash: QueryHash, status: Status, state: Map<*, *>): boolean {
// If configured with _skipCache, bypass cache altogether
if (query._skipCache) {
return false;
}

if (!this.cache.hasQueryExpired(query, state)) {
// Check if the query is in the cache. getQueryData returns a tuple; if
// the second parameter of the tuple is true we already have data for this
Expand Down
15 changes: 15 additions & 0 deletions packages/tectonic/test/specs/query/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ describe('query', () => {
assert.isFalse(q1.is(q2));
});

it('it handles the _skipCache params config', () => {
let q1, q2;
let common = {
model: User,
queryType : GET,
fields: ['name'],
returnType: RETURNS_ITEM
};

q1 = new Query({ ...common, params: { id: 1, _skipCache: true } });
q2 = new Query({ ...common, params: { id: 1 } });
assert.deepEqual(q1.params, q2.params);
assert.isTrue(q1._skipCache);
});

it('returns false with mismatching params', () => {
let q1, q2;
let common = {
Expand Down
22 changes: 22 additions & 0 deletions packages/tectonic/test/specs/resolver/baseResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,28 @@ describe('BaseResolver', () => {
}, 75);
});

it('does not use the cache when _skipCache is passed in params', (done) => {
const m = resolveAllManager();
let q = User.getItem({ id: 1 })

m.addQuery(q);
m.resolve();

window.setTimeout(() => {
let q = User.getItem({ id: 1, _skipCache: true })

const skipFromCacheSpy = sinon.spy(m.resolver, 'skipFromCache');

m.addQuery(q);
m.resolve();

assert.isTrue(skipFromCacheSpy.calledOnce);
assert.equal(skipFromCacheSpy.firstCall.returnValue, false);

done();
}, 75);
});

it('uses cache with default params foodd', () => {
const m = resolveAllManager();
// create a query which will be supplemented
Expand Down