import { ActionType , createAction } from '@ulangi/ulangi-action' ; import { ErrorBag , PixabayImage } from '@ulangi/ulangi-common/interfaces' ; import { EventBus , group , on , once } from '@ulangi/ulangi-event' ; export class UploadImageDelegate { private eventBus : EventBus ; public constructor ( eventBus ) { this . eventBus = eventBus ; } public uploadImages ( images , callback ) { this . eventBus . pubsub ( createAction ( ActionType . IMAGE__UPLOAD_IMAGES , { images , } ) , group ( on ( ActionType . IMAGE__UPLOADING_IMAGES , callback . onUploading ) , once ( ActionType . IMAGE__UPLOAD_IMAGES_SUCCEEDED , ( { urls } ) : void => callback . onUploadSucceeded ( urls ) ) , once ( ActionType . IMAGE__UPLOAD_IMAGES_FAILED , ( errorBag ) : void => callback . onUploadFailed ( errorBag ) ) ) ) ; } }