diff options
| author | taehoon <th.dev91@gmail.com> | 2019-02-13 23:25:21 -0500 |
|---|---|---|
| committer | taehoon <th.dev91@gmail.com> | 2019-02-20 13:30:31 -0500 |
| commit | 6d4d705c51a3d39e4de22a3320cfa61ef63a0066 (patch) | |
| tree | 153f393d4443e52e197176b33039a639976b7bbc /src/hocs/with_subscription | |
| parent | 339373b495f5f30833268c01d1fe958e2ee99a7f (diff) | |
Rename some options and add comments to HOCs
Diffstat (limited to 'src/hocs/with_subscription')
| -rw-r--r-- | src/hocs/with_subscription/with_subscription.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/hocs/with_subscription/with_subscription.js b/src/hocs/with_subscription/with_subscription.js index 21630b40..960c6d71 100644 --- a/src/hocs/with_subscription/with_subscription.js +++ b/src/hocs/with_subscription/with_subscription.js @@ -4,8 +4,12 @@ import isEmpty from 'lodash/isEmpty' import omit from 'lodash/omit' import './with_subscription.scss' -const withSubscription = ({ fetch, select, contentPropName = 'content' }) => (WrapperComponent) => { - const originalProps = WrapperComponent.props || [] +const withSubscription = ({ + fetch, // function to fetch entries and return a promise + select, // function to select data from store + childPropName = 'content' // name of the prop to be passed into the wrapped component +}) => (WrappedComponent) => { + const originalProps = WrappedComponent.props || [] const props = reject(originalProps, v => v === 'content') return Vue.component('withSubscription', { @@ -13,13 +17,13 @@ const withSubscription = ({ fetch, select, contentPropName = 'content' }) => (Wr const props = { props: { ...omit(this.$props, 'refresh'), - [contentPropName]: this.fetchedData + [childPropName]: this.fetchedData }, on: this.$listeners } return ( <div class="with-subscription"> - {!this.error && !this.loading && <WrapperComponent {...props} />} + {!this.error && !this.loading && <WrappedComponent {...props} />} <div class="with-subscription-footer"> {this.error && <a onClick={this.fetchData} class="alert error">{this.$t('general.generic_error')}</a>} {!this.error && this.loading && <i class="icon-spin3 animate-spin"/>} |
