Module: changeListeners/syncUserSettings

(require("changeListeners/syncUserSettings"))(userSettings) → {ext.popups.ChangeListener}

Creates an instance of the user settings sync change listener.

This change listener syncs certain parts of the state tree to user settings when they change.

Used for:

  • Enabled state: If the previews are enabled or disabled.
  • Preview count: When the user dwells on a link for long enough that a preview is shown, then their preview count will be incremented (see reducers/eventLogging.js, and is persisted to local storage.
Parameters:
Name Type Description
userSettings ext.popups.UserSettings
Source:
Returns:
Type
ext.popups.ChangeListener

Methods

(inner) get(state, reducer, prop) → {*}

Given a state tree, reducer and property, safely return the value of the property if the reducer and property exist

Parameters:
Name Type Description
state Object

tree

reducer string

key to access on the state tree

prop string

key to access on the reducer key of the state tree

Source:
Returns:
Type
*

(inner) syncIfChanged(prevState, state, reducer, prop, sync) → {void}

Calls a sync function if the property prop on the property reducer on the state trees has changed value.

Parameters:
Name Type Description
prevState Object
state Object
reducer string

key to access on the state tree

prop string

key to access on the reducer key of the state tree

sync function

function to be called with the newest value if changed

Source:
Returns:
Type
void