feat(core): support multiple responses in resource()#59573
feat(core): support multiple responses in resource()#59573alxhub wants to merge 1 commit intoangular:mainfrom
Conversation
pkozlowski-opensource
left a comment
There was a problem hiding this comment.
LGTM
Reviewed-for: public-api
Reviewed-for: fw-core
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
Quick question: would it make sense to add some tests for this change or existing tests already provide coverage for it?
atscott
left a comment
There was a problem hiding this comment.
Could you add tests for this change?
63733e8 to
0126b57
Compare
|
Whoops! Tests pushed :) |
0126b57 to
2f29528
Compare
|
Deployed adev-preview for 8164324 to: https://ng-dev-previews-fw--pr-angular-angular-59573-adev-prev-11rpbgs5.web.app Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt. |
2f29528 to
4e6017a
Compare
|
That was weird, haha. Pushed the wrong commit and the PR auto-closed. |
7fd76ca to
944372b
Compare
thePunderWoman
left a comment
There was a problem hiding this comment.
reviewed-for: fw-general, public-api
pkozlowski-opensource
left a comment
There was a problem hiding this comment.
LGTM
Reviewed-for: public-api
Reviewed-for: fw-core
This commit adds support for creating `resource()`s with streaming response
data. A streaming resource is defined by a `stream` option instead of a
`loader`, with `stream` being a function returning
`Promise<Signal<{value: T}|{error: unknown}>>`. Once the streaming loader
resolves to a `Signal`, it can continue to update that signal over time, and
the values (or errors) will be delivered to via the resource's state.
`rxResource()` is updated to leverage this new functionality to handle
multiple responses from the underlying Observable.
944372b to
8164324
Compare
|
FYI, this PR also passes TGP |
|
This PR was merged into the repository by commit bc2ad7b. The changes were merged into the following branches: main |
This commit adds support for creating `resource()`s with streaming response
data. A streaming resource is defined by a `stream` option instead of a
`loader`, with `stream` being a function returning
`Promise<Signal<{value: T}|{error: unknown}>>`. Once the streaming loader
resolves to a `Signal`, it can continue to update that signal over time, and
the values (or errors) will be delivered to via the resource's state.
`rxResource()` is updated to leverage this new functionality to handle
multiple responses from the underlying Observable.
PR Close angular#59573
With the changes in angular#59573, `resource` can now define a `stream` rather than a `loader`. In the same PR, `rxResource` was updated to leverage this new functionality to handle multiple responses from the underlying observable, rather than just the first one as it was previously. This commit renames the `loader` option of `rxResource` into `stream` to be better aligned with its new behavior. The previous version is temporarily kept and marked as deprecated to help migrating the current usage. Before ``` usersResource = rxResource({ request: () => ..., loader: ({ request }) => ... }); ``` After ``` usersResource = rxResource({ request: () => ..., stream: ({ request }) => ... }); ```
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This commit adds support for creating
resource()s with streaming response data. A streaming resource is defined by astreamoption instead of aloader, withstreambeing a function returningPromise<Signal<{value: T}|{error: unknown}>>. Once the streaming loader resolves to aSignal, it can continue to update that signal over time, and the values (or errors) will be delivered to via the resource's state.rxResource()is updated to leverage this new functionality to handle multiple responses from the underlying Observable.