connect-firebase icon indicating copy to clipboard operation
connect-firebase copied to clipboard

Add reap callback handler

Open acolby opened this issue 10 years ago • 4 comments

Hello,

First off, thanks a ton for this project is has been very helpful. I've been working on something similar, but you've done a way better job. nice work!

How do you feel about adding a callback that gets called by the reap interval function when a session is expired? Take the scenario where i add a user id to the session and add the session id to the user. If I want to reap outdated sessions from my user i would be able to handle this within the reap callback. Obviously, it would be a non-required method that would only get called if defined.

I can issue a PR for it if the contributors are interested.

Thanks!

acolby avatar Apr 09 '15 18:04 acolby

thanks and thanks also for your help. I'm not sure I understand - how would it be different than the already existing callback in the reap method?

ca98am79 avatar Apr 10 '15 17:04 ca98am79

Hey, thanks for the connector.

Line 63 uses the setInterval method to call the reap method every reapInterval milliseconds. How would I then be able to hook my own fn callback to this? Thanks again.

mcmoe avatar May 01 '15 16:05 mcmoe

my 2c, because I wrote he reap function (#5), the callback that is in there now is only used by the tests, so in line 63, to hook in your own callback that would need to be passed as an option in the initialisation as in reapInterval.

I'd suggest following the convention of one other implementation like ca98am79/connect-dynamodb or tj/connect-redis - the callback could also return the number of sessions removed

fpereira1 avatar May 01 '15 22:05 fpereira1

Hey @fpereira1, thanks for the feedback. I checked the other implementations but it doesn't seem like they implement callbacks. I implemented the idea and requested a pull request #9. Thanks again.

mcmoe avatar May 02 '15 21:05 mcmoe