Skip to content

Instantly share code, notes, and snippets.

@tilomitra
Last active October 31, 2015 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tilomitra/923e75f29e63592c05a7 to your computer and use it in GitHub Desktop.
Save tilomitra/923e75f29e63592c05a7 to your computer and use it in GitHub Desktop.
// Get all applications from the applicationList store
exports.allApplications = ['applicationList'];
// Get the search term from the searchTerm Store
exports.searchTerm = ['searchTerm'];
// Create a getter called filteredApplicationList, that takes
// the above two stores, filters the appList against the search
// query, and returns the result.
exports.filteredApplicationList = [
exports.allApplications,
exports.searchTerm,
(allApps, searchTerm) => {
var list = allApps;
if (searchTerm) {
list = allApps.filter(app => {
return (app.get('name').indexOf(searchTerm) !== -1)
});
}
return list;
}
]
var AppList = require('./path/to/AppList');
var GridView = React.createClass({
mixins: [flux.ReactMixin],
getDataBindings() {
return {
filteredApplicationList: AppList.getters.filteredApplicationList,
};
},
render() {
return (
<section className="grid-view">
// Look at this.state.filteredApplicationList array and construct a grid view
</section>
);
}
});
module.exports = GridView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment