Skip to content

Commit 0598d79

Browse files
committed
feat(post-flow): more robust in member 'params'
accept function type to generate object
1 parent 29aef47 commit 0598d79

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/app/@dataflow/rclone/post-flow.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export abstract class PostFlow<
1717
// throw new Error('Method not implemented.');
1818
// }
1919
protected abstract cmd: string;
20-
protected abstract params: object;
20+
protected abstract params: object | ((pre: CombErr<Tin>) => object);
2121
/**
2222
* auto-gen based on `cmd` and `params`
2323
*
@@ -42,7 +42,11 @@ export abstract class PostFlow<
4242
}
4343
protected request(pre: CombErr<Tin>): Observable<CombErr<Tout>> {
4444
if (pre[1].length === 0) {
45-
this.cachePath = JSON.stringify([this.cmd, this.params, pre[0].url]);
45+
if (typeof this.params === 'object')
46+
this.cachePath = JSON.stringify([this.cmd, this.params, pre[0].url]);
47+
else if (typeof this.params === 'function')
48+
this.cachePath = JSON.stringify([this.cmd, this.params(pre), pre[0].url]);
49+
else throw Error('params type is unknow.');
4650
}
4751
return super.request(pre);
4852
}

0 commit comments

Comments
 (0)