Add support for jobs & queueables, migrations
- Create migration directives & migrators - Modify Cache classes to support array manipulation - Create Redis unit and RedisCache implementation - Create Queueable base class and Queue class that uses Cache backend
This commit is contained in:
@@ -158,6 +158,8 @@ export type AsyncPipeResolver<T> = () => Awaitable<T>
|
||||
*/
|
||||
export type AsyncPipeOperator<T, T2> = (subject: T) => Awaitable<T2>
|
||||
|
||||
export type PromisePipeOperator<T, T2> = (subject: T, resolve: (val: T2) => unknown, reject: (err: Error) => unknown) => Awaitable<unknown>
|
||||
|
||||
/**
|
||||
* A closure that maps a given pipe item to an item of the same type.
|
||||
*/
|
||||
@@ -193,6 +195,23 @@ export class AsyncPipe<T> {
|
||||
return new AsyncPipe<T2>(async () => op(await this.subject()))
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a transformative operator to the pipe, wrapping it
|
||||
* in a Promise and passing the resolve/reject callbacks to the
|
||||
* closure.
|
||||
* @param op
|
||||
*/
|
||||
promise<T2>(op: PromisePipeOperator<T, T2>): AsyncPipe<T2> {
|
||||
return new AsyncPipe<T2>(() => {
|
||||
return new Promise<T2>((res, rej) => {
|
||||
(async () => this.subject())()
|
||||
.then(subject => {
|
||||
op(subject, res, rej)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply an operator to the pipe, but return the reference
|
||||
* to the current pipe. The operator is resolved when the
|
||||
|
||||
Reference in New Issue
Block a user