feat(service-worker): expose RegistrationOptions token to allow for runtime configuration#26002
feat(service-worker): expose RegistrationOptions token to allow for runtime configuration#26002deebloo wants to merge 4 commits intoangular:masterfrom
Conversation
|
Related to #22796. |
|
must not have a good job looking for an issue. I noticed that the test is failing because of public API restrictions. I was wondering the correct way going about updating those type def files. whether by hand or some tool? |
|
There is bazel command you can run to update the "golden files". It is mentioned in the CI logs: (But for small changes it is usually easier to manually update the corresponding file, service-worker.d.ts in this case.) |
|
@gkalpak i updated the PR and the public_api_guard for service-worker. Let me know if anything needs to be clarified |
|
@gkalpak I believe I have everything in order. If not then I am missing the point and need more specific direction to penetrate my thick skull 😆 |
|
@deebloo, can you give an example of a usecase that was not possible before and is possible with this change? |
|
yes. ill update the PR to show what could NOT be done before |
|
done. updated with current behavior and better example for new behavior |
|
You can preview 8632c5d at https://pr26002-8632c5d.ngbuilds.io/. |
gkalpak
left a comment
There was a problem hiding this comment.
Thx for the example. What we need:
- Squash the commits into one (that follows our guidelines).
- Add some API docs for
RegistrationOptions(see #23138 for example).
It would be rad (but not necessary for this PR) if you wanted to add an example that shows how to use this feature (and has tests to ensure it doesn't break in the future). Let me know if you are interested 😉
e6e12d6 to
3308537
Compare
|
You can preview 3308537 at https://pr26002-3308537.ngbuilds.io/. |
3308537 to
a03f9e4
Compare
|
@gkalpak id be happy to add |
|
You can preview a03f9e4 at https://pr26002-a03f9e4.ngbuilds.io/. |
a03f9e4 to
40ab248
Compare
|
@gkalpak I updated the unit tests but not really sure the best way to add an example. Let me know if you think this is good enough |
|
You can preview 40ab248 at https://pr26002-40ab248.ngbuilds.io/. |
40ab248 to
89c5338
Compare
…untime config Previously, the ServiceWorker registration options should be defined as an object literal (in order for them to be compatible with Ahead-of-Time compilation), thus making it impossible to base the ServiceWorker behavior on runtime conditions. This commit allows specifying the registration options using a regular provider, which means that it can take advantage of the `useFactory` option to determine the config at runtime, while still remaining compatible with AoT compilation.
e217161 to
1f8c38d
Compare
|
oh cool thanks @gkalpak ill keep and eye on the PR so I can see what is different |
|
@deebloo, I think it's ready. Please, take a look and let me know if you spot anything dubious 😃 More or less here is what I have done:
|
|
You can preview 1f8c38d at https://pr26002-1f8c38d.ngbuilds.io/. |
|
@gkalpak everything looks like it makes sense. I appreciate all the help getting this done. |
|
@IgorMinar, PTAL. |
|
Please, publish It's very important due to #26500 bug! |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
|
Thx for working in this, @deebloo ❤️ |
|
Of course! I do really appreciate all the assistance. |
|
Hi, is this going to be in Angular 7 as well? |
|
@znikola I don't believe so. |
|
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. |
Expose the RegistrationOptions DI token to allow for runtime configuration of ServiceWorkerModule. At the moment there is no way to mark ServiceWorkerModule as enabled at runtime since the configuration values are set at build time.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
At the moment there is no way to mark the sw module as enabled at runtime. For example if you use global variables for environment variables.
Issue Number: #22796
What is the new behavior?
Exposing this token will allow folks to configure the sw with useFactory making runtime config possible.
Does this PR introduce a breaking change?
Other information