UNPKG

863 BJavaScriptView Raw
1function preFetch (filterFunction) {
2 return function wrapWithFilter (WrappedComponent) {
3 if (WrappedComponent.__preFetchFilter == null || typeof WrappedComponent.__preFetchFilter === 'undefined') {
4 WrappedComponent.__preFetchFilter = []
5 }
6 WrappedComponent.__preFetchFilter.push((filterContext) => {
7 filterFunction(filterContext)
8 })
9 return WrappedComponent
10 }
11}
12
13function postFetch (filterFunction) {
14 return function wrapWithFilter (WrappedComponent) {
15 if (WrappedComponent.__postFetchFilter == null || typeof WrappedComponent.__postFetchFilter === 'undefined') {
16 WrappedComponent.__postFetchFilter = []
17 }
18 WrappedComponent.__postFetchFilter.push((filterContext) => {
19 filterFunction(filterContext)
20 })
21 return WrappedComponent
22 }
23}
24
25export default {
26 preFetch: preFetch,
27 postFetch: postFetch
28}