Manage react-native app's preference data synchronously
# install library from npm
npm install react-native-preference --save
import Preference from 'react-native-preference';
Preference.get(key?: String)
// get all preferences
const preferences = Preference.get();
// get preference named `some-preference`
const preference = Preference.get('some-preference');
Preference.set(key: string, value?: string): Promise<void>
// set preference
Preference.set('key', 'value');
Preference.clear(key?: string): Promise<void>
// clear all preference data
Preference.clear();
// clear preference for key 'foo'
Preference.clear('foo');
// set keys to white list, when preference value changed in white list changed, listener calls back.
Preference.setWhiteList(['a', 'b', 'c']);
Preference.addPreferenceChangedListener((changed) => {
console.log('preference has changed: changed');
});