react-native-s3 icon indicating copy to clipboard operation
react-native-s3 copied to clipboard

Add HOC for subscribe TransferUtility tasks

Open jhen0409 opened this issue 7 years ago • 0 comments

It looks like:

import React, { Component } from 'react'
import { subscribeTasks } from 'react-native-s3'

const type = 'all' // download, upload, all
const idAsKey = true
const mapTasksToProps = ({ uploadTasks, downloadTasks, methods }) => ({
  uploadTasks,
  downloadTasks,
  upload: methods.upload,
  download: methods.download,
  refresh: methods.refresh,
})
const options = { withRef: true }

const Demo = ({ uploadTasks, downloadTasks }) => {
  ......
}
export default subscribeTasks(
  type,
  idAsKey,
  mapTasksToProps,
  options
)(Demo)

Or with decorators:

@subscribeTasks(
  type,
  idAsKey,
  mapTasksToProps,
  options
)
export default class Demo extends Component {
  render() {
    const { uploadTasks, downloadTasks } = this.props
    return (
      ......
    )
  }
}

jhen0409 avatar Oct 22 '16 08:10 jhen0409