Remove use of ngResource for search and annotation queries
Several aspects of ngResource make it sub-optimal for our needs: 1. It mutates the model object directly after making an API call, which does not fit well with usage in a Redux app where the UI state should be an immutable object. 2. The ngResource classes can only be constructed once the API description has been retrieved. At least one place in our code, which handled newly created annotations arriving from the page, failed to account for this. This commit therefore replaces use of ngResource for making API calls to the search and annotation endpoints with a simple wrapper around HTTP requests which makes a call and then returns the resulting object. The new wrapper will wait until the API description has been received before attempting to make an API call, avoiding problem (2) above. As a bonus, this brings us a step towards decoupling the JS API client from Angular so we could re-use it outside the app in future. * Replace ngResource with simple $http wrapper in store.js * Add tests for annotation update and deletion API calls * Change tests in annotation-test.js from `assert(predicate(actual, expected))` form to `assert.predicate(actual, expected))` form as this results in errors that are _much_ easier to debug when they fail.
Showing
This diff is collapsed.
... | ... | @@ -61,6 +61,7 @@ |
"karma-phantomjs-launcher": "^0.2.3", | ||
"karma-sinon": "^1.0.4", | ||
"lodash.debounce": "^4.0.3", | ||
"lodash.get": "^4.3.0", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^2.4.5", | ||
"ng-tags-input": "^3.1.1", | ||
... | ... |
Please register or sign in to comment