mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
2206efa55f
Allows throwing from the resource's params function to transition the resource to a status other than resolved. In particular, the following values can be thrown from params: - `ResourceParamsStatus.IDLE` causes the resource to become `idle` (equivalent to returning `undefined`) - `ResourceParamsStatus.LOADING` causes the resource to become `loading` - Any `Error` object causes the resource to become `error` and report the error that was thrown via `.error()` To simplify chaining together resources, this PR also introduces a context object passed into to the `params` functon. This context contains a `chain` function that can be used to get the value of a resource that the params want to depend on, while automatically propagating the idle, loading, and erorr states of the resource forward.
32 lines
595 B
Python
32 lines
595 B
Python
load("//tools:defaults.bzl", "angular_jasmine_test", "ng_project", "ng_web_test_suite")
|
|
|
|
package(default_visibility = ["//visibility:private"])
|
|
|
|
ng_project(
|
|
name = "resource_lib",
|
|
testonly = True,
|
|
srcs = glob(
|
|
["**/*.ts"],
|
|
),
|
|
deps = [
|
|
"//packages/core",
|
|
"//packages/core/src/util",
|
|
"//packages/core/testing",
|
|
"//packages/private/testing",
|
|
],
|
|
)
|
|
|
|
angular_jasmine_test(
|
|
name = "resource",
|
|
data = [
|
|
":resource_lib",
|
|
],
|
|
)
|
|
|
|
ng_web_test_suite(
|
|
name = "resource_web",
|
|
deps = [
|
|
":resource_lib",
|
|
],
|
|
)
|