I have a method that calls an http request and gets a response. I need to show these results (with pagination, but thats another story). For now I need to store the initial response in (I think) a local collection so that it is easier to sort/filter the results in the UI than just an array of objects…
I’ve read about this, but was unclear on where I create this collection and how long it lasts… does the collection empty when the browser refreshes (like a session variable)? Do I create the collection in a meteor startup on the client? Or do I re-create it every time I get a response from the method?
import { composeWithTracker } from 'react-komposer';
import { Companies } from '../../../api/Companies/Companies.js';
import { NaicsCodes } from '../../../api/NaicsCodes/NaicsCodes.js';
import { JobsResults } from './jobs-results.js';
import { Loading } from '../loading.js';
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
const composer = (props, onData) => {
const subscription = Meteor.subscribe('mySubby');
if (subscription.ready()) {
Meteor.call('jobs.getJobs', companies, function(error, data){
if (error) { console.log(error); return; }
console.log(data.response.results.result); // shows an array of job post objects
let jobs = data.response.results.result;
//removed error handling, for brevity
onData(null, { jobs });
});
}
};
export default composeWithTracker(composer, Loading)(JobsResults);