(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 |
Returns:
Methods
(inner) get(state, path) → {*}
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 |
path |
string | dot-separated path in the state tree |
Returns:
- Type
- *
(inner) syncIfChanged(oldState, newState, path, 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 |
---|---|---|
oldState |
Object | |
newState |
Object | |
path |
string | dot-separated path in the state tree |
sync |
function | function to be called with the newest value if changed |
Returns:
- Type
- void