noderaider / redux-idle-monitor

A Redux component to schedule events at stages of user idleness across multiple browser tabs.
https://noderaider.github.io/redux-idle-monitor/
MIT License
105 stars 9 forks source link

Deactivate cross-tab synchronization? #21

Open Discordius opened 7 years ago

Discordius commented 7 years ago

I am actually using the package to determine polling intervals for my site, and for that use-case, synchronizing the activity state across browser intervals is actually the opposite of what I want, since I don't want the client to request new data for tabs that they aren't active in.

Is there any way to deactivate the cross-tab activity detection?

cchamberlain commented 7 years ago

@Discordius sorry for the long delay. I try and respond quickly but was out of town last week and have been busy playing catch up.

This is very similar to a request I've gotten before and I think its a reasonable thing to add support for. The previous request was to make one client "the master" that effectively did all the communications: https://github.com/noderaider/localsync/issues/2.

My current thoughts are to implement some optional arguments:

activeStatusPrimaryAction: (dispatch, getState) => void;
idleStatusPrimaryAction: (idleStatus) => (dispatch, getState) => void;

If these are passed, redux-idle-monitor would ensure they are only run on the currently active tab instead of all tabs. Can't think of a good use case or naming convention for running something on all the non-active tabs at this time so I'm only aiming to add the two above.

I was already planning on upgrading the source of this library and localsync to TypeScript - going to start on that now and will attempt to rope this functionality in, then do a major release on both.

Appreciate the request!