stevermeister / ngx-cookie-service

Angular (4.2+ ...12) service for cookies. Originally based on the `ng2-cookies` library.

Home Page:https://www.npmjs.com/package/ngx-cookie-service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support cookies.onChanged

JGhignatti opened this issue · comments

Hi,

I'd like to discuss the possibility of supporting cookies.onChanged (documentation found here) in this library. The service could wrap it and expose an Observable that components and other services could listen to.
Is it something that the lib could favor on? Is it something that the maintainers would support for the lib?

If so, I'd like to submit a PR (that I've not started yet, I'd like to get a positive from the maintainers) adding this new feature and we can discuss the implementation here or once I create the PR with the proposed solution.
If the maintainers would prefer for them to work on it, that's ok as well.

Thank you all.

@JGhignatti This is something I thought of few days ago. But the real question is why? Do you have any use case(s) that would need this functionality? And also Safari does not support this feature and it's not ideal to implement something that is not supported by all browsers.

Screen Shot 2021-08-12 at 4 54 26 PM

@stevermeister thoughts?

Thanks for answering.

The use case I first had in mind is best solved with a refresh token, but could also be solved by listening to the cookie expiring and acting on it. I understand this may not be a good solution, so no, I don't think I have a use case.

Also, I saw that Safari didn't support it, but I didn't think it was a big deal. You are right, makes no sense to implement this feature if the developers using the lib would have to write workarounds for the Safari browser.
Implementing a onChanged by hand could work, like this lib, but once again doesn't feel like a good idea.