mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-27 04:05:10 +00:00
Add types for uppy.once method (#2965)
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
This commit is contained in:
parent
ee2f527395
commit
3c8fbe8d87
3 changed files with 16 additions and 12 deletions
|
|
@ -15,8 +15,8 @@
|
|||
* will expire before some files can be uploaded.
|
||||
*
|
||||
* The long-term solution to this problem is to change the upload pipeline so that files
|
||||
* can be sent to the next step individually. That requires a breakig change, so it is
|
||||
* planned for Uppy v2.
|
||||
* can be sent to the next step individually. That requires a breaking change, so it is
|
||||
* planned for some future Uppy version.
|
||||
*
|
||||
* In the mean time, this plugin is stuck with a hackier approach: the necessary parts
|
||||
* of the XHRUpload implementation were copied into this plugin, as the MiniXHRUpload
|
||||
|
|
|
|||
16
packages/@uppy/core/types/index.d.ts
vendored
16
packages/@uppy/core/types/index.d.ts
vendored
|
|
@ -147,17 +147,17 @@ declare module Uppy {
|
|||
|
||||
type UploadHandler = (fileIDs: string[]) => Promise<void>
|
||||
|
||||
type UploadSuccessCallback<T> = (file: UppyFile<T>, body: any, uploadURL: string) => void
|
||||
type UploadCompleteCallback<T> = (result: UploadResult<T>) => void
|
||||
|
||||
class Uppy<TUseStrictTypes extends TypeChecking = TypeChecking> {
|
||||
constructor(opts?: UppyOptions)
|
||||
on<TMeta extends IndexedObject<any> = {}>(
|
||||
event: 'upload-success',
|
||||
callback: (file: UppyFile<TMeta>, body: any, uploadURL: string) => void
|
||||
): this
|
||||
on<TMeta extends IndexedObject<any> = {}>(
|
||||
event: 'complete',
|
||||
callback: (result: UploadResult<TMeta>) => void
|
||||
): this
|
||||
on<TMeta extends IndexedObject<any> = {}>(event: 'upload-success', callback: UploadSuccessCallback<TMeta>): this
|
||||
on<TMeta extends IndexedObject<any> = {}>(event: 'complete', callback: UploadCompleteCallback<TMeta>): this
|
||||
on(event: Event, callback: (...args: any[]) => void): this
|
||||
once<TMeta extends IndexedObject<any> = {}>(event: 'upload-success', callback: UploadSuccessCallback<TMeta>): this
|
||||
once<TMeta extends IndexedObject<any> = {}>(event: 'complete', callback: UploadCompleteCallback<TMeta>): this
|
||||
once(event: Event, callback: (...args: any[]) => void): this
|
||||
off(event: Event, callback: (...args: any[]) => void): this
|
||||
/**
|
||||
* For use by plugins only.
|
||||
|
|
|
|||
|
|
@ -81,13 +81,17 @@ import DefaultStore = require('@uppy/store-default')
|
|||
// can emit events with custom event types
|
||||
uppy.emit('dashboard:modal-closed', () => {})
|
||||
|
||||
// can register listners for internal events
|
||||
// can register listeners for internal events
|
||||
uppy.on('upload', () => {})
|
||||
uppy.on('complete', () => {})
|
||||
uppy.on('error', () => {})
|
||||
uppy.once('upload', () => {})
|
||||
uppy.once('complete', () => {})
|
||||
uppy.once('error', () => {})
|
||||
|
||||
// can register listners on custom events
|
||||
// can register listeners on custom events
|
||||
uppy.on('dashboard:modal-closed', () => {})
|
||||
uppy.once('dashboard:modal-closed', () => {})
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue