FuseJS/UserSettings module provides key-value pairs mechanism to store and retrieve primitive data types (string, number, boolean) as well as an array and json object. You can use this module to store information such as configuration data, application states etc.

UserSettings module is implemented atop NSUserDefaults on iOS and Shared Preferences on Android

Example

<JavaScript>
    var userSettings = require("FuseJS/UserSettings")

    userSettings.putString('email', 'john.appleseed@example.com');
    userSettings.putString('password', 's3c1ReT');
    userSettings.putString('api_token', '73awnljqurelcvxiy832a');
    userSettings.putBoolean('logged', true);
    userSettings.putNumber('state_num', 2);
    userSettings.putArray('preferences', ['Technology', 'Cars', 'Foods']);
    userSettings.putObject('profile', {
        'first_name': 'John',
        'last_name': 'Appleseed',
        'gender': 'male',
        'address': '5 avenue'
        'age': 25,
        'married': false
    });

    var email = userSettings.getString('email');
    var password = userSettings.getString('password');
    var api_token = userSettings.getString('api_token');
    var logged = userSettings.getBoolean('logged');
    var state_num = userSettings.getNumber('state_num');
    var preferences = userSettings.getArray('preferences');
    var profile = userSettings.getObject('profile');
</JavaScript>

Location

Namespace
Fuse.Storage
Package
Fuse.Storage 2.9.1
Show Uno properties and methods

Interface of UserSettingsModule

Inherited from NativeModule

Inherited from Module

GetFile : FileSource uno

Returns the file source that will be watched by the Context for changes in Fuse preview. Override in subclasses and return correct file source to support live updates in Fuse preview.

Inherited from object

Attached UX Attributes

GlobalKey (attached by Resource) : string ux

The ux:Global attribute creates a global resource that is accessible everywhere in UX markup.

Implemented Interfaces