From e3a141aaceb00312e7dfd20b2c9e418a6d1e3ed0 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 8 Apr 2015 01:42:20 +0000 Subject: [PATCH] update website --- docs/asyncstorage.html | 58 ++++++++++++++++++++---------------------- docs/navigator.html | 7 ++--- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/docs/asyncstorage.html b/docs/asyncstorage.html index 92cf49b5fbb..b2d90743ab3 100644 --- a/docs/asyncstorage.html +++ b/docs/asyncstorage.html @@ -2,14 +2,15 @@ system. It should be used instead of LocalStorage.

It is recommended that you use an abstraction on top of AsyncStorage instead of AsyncStorage directly for anything more than light usage since it operates globally.

This JS code is a simple facad over the native iOS implementation to provide -a clear JS API, real Error objects, and simple non-multi functions.

Methods #

static getItem(key: string, callback: (error: ?Error, result: ?string) => void) #

Fetches key and passes the result to callback, along with an Error if -there is any.

static setItem(key: string, value: string, callback: ?(error: ?Error) => void) #

Sets value for key and calls callback on completion, along with an -Error if there is any.

static removeItem(key: string, callback: ?(error: ?Error) => void) #

static mergeItem(key: string, value: string, callback: ?(error: ?Error) => void) #

Merges existing value with input value, assuming they are stringified json.

Not supported by all native implementations.

static clear(callback: ?(error: ?Error) => void) #

Erases all AsyncStorage for all clients, libraries, etc. You probably +a clear JS API, real Error objects, and simple non-multi functions. Each +method returns a Promise object.

Methods #

static getItem(key: string, callback: (error: ?Error, result: ?string) => void) #

Fetches key and passes the result to callback, along with an Error if +there is any. Returns a Promise object.

static setItem(key: string, value: string, callback: ?(error: ?Error) => void) #

Sets value for key and calls callback on completion, along with an +Error if there is any. Returns a Promise object.

static removeItem(key: string, callback: ?(error: ?Error) => void) #

Returns a Promise object.

static mergeItem(key: string, value: string, callback: ?(error: ?Error) => void) #

Merges existing value with input value, assuming they are stringified json. Returns a Promise object.

Not supported by all native implementations.

static clear(callback: ?(error: ?Error) => void) #

Erases all AsyncStorage for all clients, libraries, etc. You probably don't want to call this - use removeItem or multiRemove to clear only your -own keys instead.

static getAllKeys(callback: (error: ?Error) => void) #

Gets all keys known to the system, for all callers, libraries, etc.

static multiGet(keys: Array<string>, callback: (errors: ?Array<Error>, result: ?Array<Array<string>>) => void) #

multiGet invokes callback with an array of key-value pair arrays that -matches the input format of multiSet.

multiGet(['k1', 'k2'], cb) -> cb([['k1', 'val1'], ['k2', 'val2']])

static multiSet(keyValuePairs: Array<Array<string>>, callback: ?(errors: ?Array<Error>) => void) #

multiSet and multiMerge take arrays of key-value array pairs that match -the output of multiGet, e.g.

multiSet([['k1', 'val1'], ['k2', 'val2']], cb);

static multiRemove(keys: Array<string>, callback: ?(errors: ?Array<Error>) => void) #

Delete all the keys in the keys array.

static multiMerge(keyValuePairs: Array<Array<string>>, callback: ?(errors: ?Array<Error>) => void) #

Merges existing values with input values, assuming they are stringified -json.

Not supported by all native implementations.

Edit on GitHubExamples #

'use strict'; +own keys instead. Returns a Promise object.

static getAllKeys(callback: (error: ?Error) => void) #

Gets all keys known to the system, for all callers, libraries, etc. Returns a Promise object.

static multiGet(keys: Array<string>, callback: (errors: ?Array<Error>, result: ?Array<Array<string>>) => void) #

multiGet invokes callback with an array of key-value pair arrays that +matches the input format of multiSet. Returns a Promise object.

multiGet(['k1', 'k2'], cb) -> cb([['k1', 'val1'], ['k2', 'val2']])

static multiSet(keyValuePairs: Array<Array<string>>, callback: ?(errors: ?Array<Error>) => void) #

multiSet and multiMerge take arrays of key-value array pairs that match +the output of multiGet, e.g. Returns a Promise object.

multiSet([['k1', 'val1'], ['k2', 'val2']], cb);

static multiRemove(keys: Array<string>, callback: ?(errors: ?Array<Error>) => void) #

Delete all the keys in the keys array. Returns a Promise object.

static multiMerge(keyValuePairs: Array<Array<string>>, callback: ?(errors: ?Array<Error>) => void) #

Merges existing values with input values, assuming they are stringified +json. Returns a Promise object.

Not supported by all native implementations.

Edit on GitHubExamples #

'use strict'; var React = require('react-native'); var { @@ -25,16 +26,17 @@ json.

Not supported by all native implementations.

var BasicStorageExample = React.createClass({ componentDidMount() { - AsyncStorage.getItem(STORAGE_KEY, (error, value) => { - if (error) { - this._appendMessage('AsyncStorage error: ' + error.message); - } else if (value !== null) { - this.setState({selectedValue: value}); - this._appendMessage('Recovered selection from disk: ' + value); - } else { - this._appendMessage('Initialized with no selection on disk.'); - } - }); + AsyncStorage.getItem(STORAGE_KEY) + .then((value) => { + if (value !== null){ + this.setState({selectedValue: value}); + this._appendMessage('Recovered selection from disk: ' + value); + } else { + this._appendMessage('Initialized with no selection on disk.'); + } + }) + .catch((error) => this._appendMessage('AsyncStorage error: ' + error.message)) + .done(); }, getInitialState() { return { @@ -77,23 +79,17 @@ json.

Not supported by all native implementations.

_onValueChange(selectedValue) { this.setState({selectedValue}); - AsyncStorage.setItem(STORAGE_KEY, selectedValue, (error) => { - if (error) { - this._appendMessage('AsyncStorage error: ' + error.message); - } else { - this._appendMessage('Saved selection to disk: ' + selectedValue); - } - }); + AsyncStorage.setItem(STORAGE_KEY, selectedValue) + .then(() => this._appendMessage('Saved selection to disk: ' + selectedValue)) + .catch((error) => this._appendMessage('AsyncStorage error: ' + error.message)) + .done(); }, _removeStorage() { - AsyncStorage.removeItem(STORAGE_KEY, (error) => { - if (error) { - this._appendMessage('AsyncStorage error: ' + error.message); - } else { - this._appendMessage('Selection removed from disk.'); - } - }); + AsyncStorage.removeItem(STORAGE_KEY) + .then(() => this._appendMessage('Selection removed from disk.')) + .catch((error) => { this._appendMessage('AsyncStorage error: ' + error.message) }) + .done(); }, _appendMessage(message) { diff --git a/docs/navigator.html b/docs/navigator.html index 0a196bc0009..0c95ec15924 100644 --- a/docs/navigator.html +++ b/docs/navigator.html @@ -44,11 +44,8 @@ complete or after the initial mounting. This overrides the onDidFocus handler that would be found in this.props.navigator

onItemRef function #

Will be called with (ref, indexInStack) when the scene ref changes

onWillFocus function #

Will emit the target route upon mounting and before each nav transition, overriding the handler in this.props.navigator. This overrides the onDidFocus handler that would be found in this.props.navigator

renderScene function #

Required function which renders the scene for a given route. Will be -invoked with the route, the navigator object, and a ref handler that -will allow a ref to your scene to be provided by props.onItemRef

(route, navigator, onRef) => - <MySceneComponent title={route.title} ref={onRef} />

sceneStyle View#style #

Styles to apply to the container of each scene

shouldJumpOnBackstackPop bool #

Should the backstack back button "jump" back instead of pop? Set to true -if a jump forward might happen after the android back button is pressed, -so the scenes will remain mounted

Next →