/* * mode 如果处理 next 函数 * Null 不处理 * Append 在整个传播过程结束的时候,将所有的数据将被打包为一个数组传入 next, 如果出现 error,则立即中断,传回错误信息 */ export default class Request { public async: boolean public path: string public data: any public query: {[key: string]: string} = {} // 为 Listener 类准备 private resolve: Function private isFulfill: boolean = false private responseData: any = null private responseError: any = null constructor(path: string, data: any, resolve: Function, async: boolean) { this.path = path this.data = data this.async = async this.resolve = resolve if (!this.async) this.resolve({ data: null, error: null }) } public next(data: any, error: any) :void { this.resolve({ data, error }) } }