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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): introducing EffectHttpResponse type #87
Conversation
Codecov Report
@@ Coverage Diff @@
## next #87 +/- ##
===================================
Coverage 100% 100%
===================================
Files 45 45
Lines 499 499
Branches 62 62
===================================
Hits 499 499
Continue to review full report at Codecov.
|
@@ -13,8 +16,12 @@ export interface Middleware< | |||
> extends Effect<I, O> {} | |||
|
|||
export interface ErrorEffect<T extends Error = Error> | |||
extends Effect<HttpRequest, EffectResponse, T> {} | |||
extends Effect<HttpRequest, EffectHttpResponse, T> {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it extends Effect<HttpRequest, EffectHttpResponse>, shouldn't it be HttpErrorEffect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I will name it as HttpErrorEffect
then it will be a huge breaking change because constructs like Effect
, ErrorEffect
, Middleware
are more commonly used compared to raw Error<..., ...>
definitions. 馃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe ErrorEffect
should be more generic? Eg. like Middleware
馃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, if the Effect
and ErrorEffect
should be HTTP independent then both ErrorEffect
, Middleware
and base Effect
interfaces should have an ability to construct new types upon it:
export interface Middleware<
I extends HttpRequest = HttpRequest,
O extends HttpRequest = HttpRequest,
T = HttpResponse
> extends Effect<I, O, any, T> {}
export interface ErrorEffect<
T extends Error = Error,
U = HttpRequest,
V = EffectHttpResponse,
> extends Effect<U, V, T> {}
export interface Effect<
T = HttpRequest,
U = EffectHttpResponse,
V = any,
W = HttpResponse,
> {
(req$: Observable<T>, res: W, meta: V): Observable<U>;
}
@krzysztof-miemiec WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we can construct new Websockets-related interfaces for WsEffect
, WsErrorEffect
and WsMiddleware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or to only define the fully compassable Effect
interface and leave ErrorEffect
and Middleware
as it is.
export interface Effect<
T = HttpRequest,
U = EffectHttpResponse,
V = any,
W = HttpResponse,
> {
(req$: Observable<T>, res: W, meta: V): Observable<U>;
}
Then we can create WsEffect
, WsErrorEffect
and WsMiddleware
types basing only on 鈽濓笍 it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the better is the last solution. 馃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think that the latter solution would be best. Default way of working with Marble would be HTTP, and WS is added as additional feature. 馃憣 BTW. Should we add support for server push (with http2) in Marble.js 2.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but these are our priorities for v2.0:
Websockets
>> http2
4821613
to
938944f
Compare
PR Type
What kind of change does this PR introduce?
What is the current behavior?
EffectResponse
interface is restricted only to HTTP protocol. It should be only represented as a base type which could be used outside, eg. in websockets protocol.What is the new behavior?
Effect
generic interface extendsEffectResponse
defaulting toEffectHttpResponse
type - because we are targeting HTTP protocol by default. From now it allows us to build Effects, not restricted only to HTTP protocol.lint-staged
to version8.1.0
馃憠 removedrxjs-compat
Does this PR introduce a breaking change?