Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
feat(s3): callbacks & s3 instance
Browse files Browse the repository at this point in the history
  • Loading branch information
rnicholus committed Oct 26, 2016
1 parent 1c337c1 commit f4bb28c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/wrappers/base-wrapper.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import objectAssign from 'object-assign'
import qq from 'fine-uploader/lib/core'

import CallbackProxy from './callback-proxy'
import { traditional as callbackNames } from './callback-names'

const callbackProxies = new WeakMap()

export default class BaseWrapper {
constructor({ options, type }) {
constructor({ callbackNames, options, qq, type }) {
const callbacks = options.callbacks || {}

const optionsSansCallbacks = objectAssign({}, options)
Expand All @@ -21,6 +19,7 @@ export default class BaseWrapper {
this.methods = createFineUploader({
callbackProxies: callbackProxies.get(this),
options: optionsSansCallbacks,
qq,
type
})
}
Expand Down Expand Up @@ -50,7 +49,7 @@ const createCallbackProxies = names => {
return proxyMap
}

const createFineUploader = ({ callbackProxies, options, type } ) => {
const createFineUploader = ({ callbackProxies, options, qq, type } ) => {
const optionsCopy = objectAssign({ callbacks: {} }, options)

Object.keys(callbackProxies).forEach(callbackName => {
Expand Down
6 changes: 6 additions & 0 deletions src/wrappers/callback-names.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import objectAssign from 'object-assign'

export const thenable = [
'onCancel',
'onPasteReceived',
Expand Down Expand Up @@ -31,3 +33,7 @@ export const traditional = [
'onValidate',
'onValidateBatch'
]

export const s3 = objectAssign([], traditional, [
'onCredentialsExpired'
])
9 changes: 8 additions & 1 deletion src/wrappers/s3.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import BaseWrapper from './base-wrapper'
import qq from 'fine-uploader/lib/core/s3'
import { s3 as callbackNames } from './callback-names'

export default class FineUploaderS3 extends BaseWrapper {
constructor({ options }) {
super({ options, type: 's3' })
super({
callbackNames,
options,
qq,
type: 's3'
})
}
}
9 changes: 8 additions & 1 deletion src/wrappers/traditional.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import BaseWrapper from './base-wrapper'
import qq from 'fine-uploader/lib/core'
import { traditional as callbackNames } from './callback-names'

export default class FineUploaderTraditional extends BaseWrapper {
constructor({ options }) {
super({ options, type: 'traditional' })
super({
callbackNames,
options,
qq,
type: 'traditional'
})
}
}

0 comments on commit f4bb28c

Please sign in to comment.