Created
April 15, 2018 11:02
-
-
Save theKashey/4802b0e9bcc448f792955699042ca1f7 to your computer and use it in GitHub Desktop.
Table gDSFP+flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// base - https://github.com/reactjs/rfcs/pull/40#discussion_r180818891 | |
import memoize from "lodash.memoize"; | |
import flow from "lodash.flow"; | |
class Example { | |
getSortedData = memoize((list, sortFn) => list.slice().sort(sortFn)) | |
getPagedData = memoize((list, page) => list.slice(page*10, (page+1)*10)) | |
render() { | |
const theFlow = flow( | |
// sort | |
(data) => this.getSortedData(data,this.props.sort) | |
// slice | |
(sorted) => this.getPagedData(sorted, this.props.page) | |
); | |
const paged = theFlow(this.props.data); | |
// Render with this.props, this.state, and derived values ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment