• JMap.User.setPreference

    Set a user preference in user storage. The returned Promise resolves without value on success. Rejects with a reason on error, or if name parameter is not string or empty string, or if no user is logged in If passed value is undefined, the preference is removed

    Parameters

    • name: string

      the name of the preference

    • value: undefined | string

      the value that will be associated to the name

    Returns Promise<void>

    a Promise that sets the user preference, and resolves with no value, or rejects with a reason

    Example

    let prefName = "jmapserver-ng-core-basemap"

    // Set the value "light" for user preference "jmapserver-ng-core-basemap"
    JMap.User
    .setPreference(prefName, "light")
    .then(preferenceValue => console.log(`Preference item "${prefName}" has been set`))
    .catch(reason => console.log(`Cannot set the preference value of param "${prefName}". Reason: ${reason}`))

    // Remove the value for user preference "theme"
    JMap.User
    .removePreference(prefName)
    .then(preferenceValue => console.log(`Preference item "${prefName}" has been removed, and its value were "${preferenceValue}""`))
    .catch(reason => console.log(`Cannot remove the preference "${prefName}". Reason: ${reason}`))