-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] midway controller supports returning Observable #274
Comments
粗略想了一下。。没理解。。。有示例么? |
大致这样: import { Context, config, controller, get, provide } from 'midway'
import { Observable, timer } from 'rxjs'
import { map } from 'rxjs/operators'
@provide()
@controller('/')
export class HomeController {
constructor(
@config() private readonly welcomeMsg: string,
) {}
@get('/', { middleware: ['apiMiddleware'] })
public index(ctx: Context): Observable<string> {
return timer(5000).pipe(
map(() => {
return `${ this.welcomeMsg } - ${ ctx.api.reqTimeStr }`
})
)
}
} 返回的是 |
这个貌似没见过。。。虽然看过nest有这样搞。。不过他是配合他的整个流程,加上拦截器,包了 express,而koa 这边因为本身自带了洋葱模型,所以再写一个就很奇怪。可能 Observable 可以作为核心能力的一部分,甚至单独出一个 Midway-Observable 来尝试写法都可以。 |
是的,这个改动会比较大。 |
所以可能得来个 midway for rxjs ? |
估计 midway grpc 优先级还高些。 |
😄 GRPC。。在做faas的时候用到了,发现和java交互有点问题。。 |
和 golang 交互没问题吧。那锅就是 java 的了嘛…… |
没错,就是java的锅。 |
Midway 的 controller 能否支持直接返回 (rxjs 的) Observable 对象。
nestjs 支持,感觉是比较方便的。
The text was updated successfully, but these errors were encountered: