componentDidMount() {
   AsyncStorage.getItem(this._cacheKey, (err, value) => {
     if (!err && value) {
       this.setState({value: JSON.parse(value)});
     }
   });
 }
Esempio n. 2
0
 Linking.getInitialURL().then(url => {
   AsyncStorage.getItem(APP_STATE_KEY, (err, storedString) => {
     const exampleAction = URIActionMap(
       this.props.exampleFromAppetizeParams,
     );
     const urlAction = URIActionMap(url);
     const launchAction = exampleAction || urlAction;
     const initialAction = launchAction || {type: 'InitialAction'};
     this.setState(RNTesterNavigationReducer(undefined, initialAction));
   });
 });
Esempio n. 3
0
api.init = function() {

  asyncStorage.getItem(dcfConfig.key, function(value) {

    dcfConfigLoaded = true;
    dcfConfig.seq = value ? value : defaultSeq;

    // We have a previous call to createDCFFilename that is waiting for
    // a response, fire it again
    if (deferredArgs) {
      var args = deferredArgs;
      api.createDCFFilename(args.storage, args.type, args.callback);
      deferredArgs = null;
    }
  });
};
 Linking.getInitialURL().then((url) => {
   AsyncStorage.getItem(APP_STATE_KEY, (err, storedString) => {
     const exampleAction = URIActionMap(this.props.exampleFromAppetizeParams);
     const urlAction = URIActionMap(url);
     const launchAction = exampleAction || urlAction;
     if (err || !storedString) {
       const initialAction = launchAction || {type: 'InitialAction'};
       this.setState(RNTesterNavigationReducer(null, initialAction));
       return;
     }
     const storedState = JSON.parse(storedString);
     if (launchAction) {
       this.setState(RNTesterNavigationReducer(storedState, launchAction));
       return;
     }
     this.setState(storedState);
   });
 });
 componentDidMount() {
   if (this.props.LinkingActionMap) {
     Linking.getInitialURL().then(this._handleOpenURL.bind(this));
     Platform.OS === 'ios' && Linking.addEventListener('url', this._handleOpenURLEvent);
   }
   if (this.props.persistenceKey) {
     AsyncStorage.getItem(this.props.persistenceKey, (err, storedString) => {
       if (err || !storedString) {
         this.setState({
           navState: this.props.reducer(null, this.props.initialAction),
         });
         return;
       }
       this.setState({
         navState: JSON.parse(storedString),
       });
     });
   }
 }
'use strict';

import AsyncStorage from 'AsyncStorage';
import Config from '../../Config';

export default {
  /**
   * Get or get token
   * @param [token]
   * @returns {Promise.<string|null>}
   */
  token(token = null) {
    if (token) {
      return AsyncStorage.setItem(Config.AUTHORIZATION_STORAGE_KEY, token)
        .then(e => token);
    } else {
      return AsyncStorage.getItem(Config.AUTHORIZATION_STORAGE_KEY);
    }
  },

  /**
   * Destroy session token
   * @returns {Promise}
   */
  destroy() {
    return AsyncStorage.removeItem(Config.AUTHORIZATION_STORAGE_KEY);
  }
};
    external: true,
  },

  getInitialState: function() {
    return {
      example: null,
    };
  },

  componentDidMount() {
    AsyncStorage.getItem(EXAMPLE_STORAGE_KEY, (err, example) => {
      if (err || !example || !EXAMPLES[example]) {
        this.setState({
          example: 'menu',
        });
        return;
      }
      this.setState({
        example,
      });
    });
  },

  setExample: function(example) {
    this.setState({
      example,
    });
    AsyncStorage.setItem(EXAMPLE_STORAGE_KEY, example);
  },

  _renderMenu: function() {