ngneat / cashew

🐿 A flexible and straightforward library that caches HTTP requests in Angular
https://www.netbasal.com
MIT License
682 stars 33 forks source link

Current example of ParameterEncoder override in config breaks AOT compilation #17

Closed mokipedia closed 4 years ago

mokipedia commented 4 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

Currently parameterCodec in config as it is shown in the readme does not work für AOT compilation. The problem is the constructor call of new CustomHttpParamEncoder() in @NgModule.

Expected behavior

possibility to give CustomHttpParamEncoder to config so the request params are correctly encoded / decoded.

Minimal reproduction of the problem with instructions

add parameterEncoder to config and compile with AOT.

Environment


Angular version: 7,8,9


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:
- Node version: v14.1.0  
- Platform:  Mac

Others:

mokipedia commented 4 years ago

One way to solve this is to use a object literal instead of a class instance for CustomParameterEncoder. However this seems to have some issues after prod build and sometimes simply does not work as expected.

Another way would be to give only the Class reference to config and instantiate it in HttpCacheInterceptor. However this would be a breaking change.