moribvndvs / ng2-idle

Responding to idle users in Angular (not AngularJS) applications.
https://moribvndvs.github.io/ng2-idle
Apache License 2.0
315 stars 128 forks source link

Feature request: allow keepalive.request() to accept a function #57

Closed VeryBueno closed 7 years ago

VeryBueno commented 7 years ago

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/HackedByChinese/ng2-idle/blob/master/CONTRIBUTING.md#getting-help

Current behavior

The keepalive module accepts a string or Request in request() for configuring the ping request.

Expected behavior

I'd like to have the ability to pass a function that returns a promise.

Minimal reproduction of the problem with instructions

n/a

What is the motivation / use case for changing the behavior?

I have an app that needs to add special headers to HTTP requests. I extended Angular's Http to enable this. I'd rather use a service that I already wrote instead of manually constructing the Request to pass to keepalive.request().

Please tell us about your environment:

Idea, npm, linux

Thank you!

moribvndvs commented 7 years ago

You do not have to use request. If you'd like to handle the actual pinging logic yourself, just subscribe to Keepalive.onPing and do whatever you'd like.

See Extend your app component for a trivial example of how to subscribe to the event.