mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Deploy website
Deploy website version based on 92b0daa2025af39dc0870960af6f871c898da4cd
This commit is contained in:
@@ -129,7 +129,7 @@
|
||||
<h3><a class="anchor" aria-hidden="true" id="registercancellableheadlesstask"></a><a href="#registercancellableheadlesstask" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>registerCancellableHeadlessTask()</code></h3>
|
||||
<pre><code class="hljs css language-javascript"><span class="token keyword">static</span> <span class="token function">registerCancellableHeadlessTask</span><span class="token punctuation">(</span>taskKey<span class="token punctuation">,</span> taskProvider<span class="token punctuation">,</span> taskCancelProvider<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h2><a class="anchor" aria-hidden="true" id="register-a-headless-task-which-can-be-cancelled-a-headless-task-is-a-bit-of-code-that-runs-without-a-ui-param-taskkey-the-key-associated-with-this-task-param-taskprovider-a-promise-returning-function-that-takes-some-data-passed-from-the-native-side-as-the-only-argument-when-the-promise-is-resolved-or-rejected-the-native-side-is-notified-of-this-event-and-it-may-decide-to-destroy-the-js-context-param-taskcancelprovider-a-void-returning-function-that-takes-no-arguments-when-a-cancellation-is-requested-the-function-being-executed-by-taskprovider-should-wrap-up-and-return-asap"></a><a href="#register-a-headless-task-which-can-be-cancelled-a-headless-task-is-a-bit-of-code-that-runs-without-a-ui-param-taskkey-the-key-associated-with-this-task-param-taskprovider-a-promise-returning-function-that-takes-some-data-passed-from-the-native-side-as-the-only-argument-when-the-promise-is-resolved-or-rejected-the-native-side-is-notified-of-this-event-and-it-may-decide-to-destroy-the-js-context-param-taskcancelprovider-a-void-returning-function-that-takes-no-arguments-when-a-cancellation-is-requested-the-function-being-executed-by-taskprovider-should-wrap-up-and-return-asap" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Register a headless task which can be cancelled. A headless task is a bit of code that runs without a UI. @param taskKey the key associated with this task @param taskProvider a promise returning function that takes some data passed from the native side as the only argument; when the promise is resolved or rejected the native side is notified of this event and it may decide to destroy the JS context. @param taskCancelProvider a void returning function that takes no arguments; when a cancellation is requested, the function being executed by taskProvider should wrap up and return ASAP.</h2>
|
||||
<p>Register a headless task which can be cancelled. A headless task is a bit of code that runs without a UI. @param taskKey the key associated with this task @param taskProvider a promise returning function that takes some data passed from the native side as the only argument; when the promise is resolved or rejected the native side is notified of this event and it may decide to destroy the JS context. @param taskCancelProvider a void returning function that takes no arguments; when a cancellation is requested, the function being executed by taskProvider should wrap up and return ASAP.</p>
|
||||
<h3><a class="anchor" aria-hidden="true" id="startheadlesstask"></a><a href="#startheadlesstask" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>startHeadlessTask()</code></h3>
|
||||
<pre><code class="hljs css language-javascript"><span class="token keyword">static</span> <span class="token function">startHeadlessTask</span><span class="token punctuation">(</span>taskId<span class="token punctuation">,</span> taskKey<span class="token punctuation">,</span> data<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
<h3><a class="anchor" aria-hidden="true" id="registercancellableheadlesstask"></a><a href="#registercancellableheadlesstask" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>registerCancellableHeadlessTask()</code></h3>
|
||||
<pre><code class="hljs css language-javascript"><span class="token keyword">static</span> <span class="token function">registerCancellableHeadlessTask</span><span class="token punctuation">(</span>taskKey<span class="token punctuation">,</span> taskProvider<span class="token punctuation">,</span> taskCancelProvider<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h2><a class="anchor" aria-hidden="true" id="register-a-headless-task-which-can-be-cancelled-a-headless-task-is-a-bit-of-code-that-runs-without-a-ui-param-taskkey-the-key-associated-with-this-task-param-taskprovider-a-promise-returning-function-that-takes-some-data-passed-from-the-native-side-as-the-only-argument-when-the-promise-is-resolved-or-rejected-the-native-side-is-notified-of-this-event-and-it-may-decide-to-destroy-the-js-context-param-taskcancelprovider-a-void-returning-function-that-takes-no-arguments-when-a-cancellation-is-requested-the-function-being-executed-by-taskprovider-should-wrap-up-and-return-asap"></a><a href="#register-a-headless-task-which-can-be-cancelled-a-headless-task-is-a-bit-of-code-that-runs-without-a-ui-param-taskkey-the-key-associated-with-this-task-param-taskprovider-a-promise-returning-function-that-takes-some-data-passed-from-the-native-side-as-the-only-argument-when-the-promise-is-resolved-or-rejected-the-native-side-is-notified-of-this-event-and-it-may-decide-to-destroy-the-js-context-param-taskcancelprovider-a-void-returning-function-that-takes-no-arguments-when-a-cancellation-is-requested-the-function-being-executed-by-taskprovider-should-wrap-up-and-return-asap" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Register a headless task which can be cancelled. A headless task is a bit of code that runs without a UI. @param taskKey the key associated with this task @param taskProvider a promise returning function that takes some data passed from the native side as the only argument; when the promise is resolved or rejected the native side is notified of this event and it may decide to destroy the JS context. @param taskCancelProvider a void returning function that takes no arguments; when a cancellation is requested, the function being executed by taskProvider should wrap up and return ASAP.</h2>
|
||||
<p>Register a headless task which can be cancelled. A headless task is a bit of code that runs without a UI. @param taskKey the key associated with this task @param taskProvider a promise returning function that takes some data passed from the native side as the only argument; when the promise is resolved or rejected the native side is notified of this event and it may decide to destroy the JS context. @param taskCancelProvider a void returning function that takes no arguments; when a cancellation is requested, the function being executed by taskProvider should wrap up and return ASAP.</p>
|
||||
<h3><a class="anchor" aria-hidden="true" id="startheadlesstask"></a><a href="#startheadlesstask" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>startHeadlessTask()</code></h3>
|
||||
<pre><code class="hljs css language-javascript"><span class="token keyword">static</span> <span class="token function">startHeadlessTask</span><span class="token punctuation">(</span>taskId<span class="token punctuation">,</span> taskKey<span class="token punctuation">,</span> data<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<h2><a class="anchor" aria-hidden="true" id="the-toast-module"></a><a href="#the-toast-module" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>The Toast Module</h2>
|
||||
<p>This guide will use the <a href="http://developer.android.com/reference/android/widget/Toast.html">Toast</a> example. Let's say we would like to be able to create a toast message from JavaScript.</p>
|
||||
<p>We start by creating a native module. A native module is a Java class that usually extends the <code>ReactContextBaseJavaModule</code> class and implements the functionality required by the JavaScript. Our goal here is to be able to write <code>ToastExample.show('Awesome', ToastExample.SHORT);</code> from JavaScript to display a short toast on the screen.</p>
|
||||
<p>create a new Java Class named <code>ToastModule.java</code> inside <code>android/app/src/main/java/com/your-app-name/</code> folder with the content below:</p>
|
||||
<p>Create a new Java Class named <code>ToastModule.java</code> inside <code>android/app/src/main/java/com/your-app-name/</code> folder with the content below:</p>
|
||||
<pre><code class="hljs css language-java"><span class="token comment">// ToastModule.java</span>
|
||||
|
||||
<span class="token keyword">package</span> com<span class="token punctuation">.</span>your<span class="token operator">-</span>app<span class="token operator">-</span>name<span class="token punctuation">;</span>
|
||||
@@ -150,6 +150,7 @@ R<span class="hljs-function"><span class="hljs-title">eadableArray</span> -><
|
||||
<span class="token punctuation">}</span>
|
||||
</code></pre>
|
||||
<p>To make it simpler to access your new functionality from JavaScript, it is common to wrap the native module in a JavaScript module. This is not necessary but saves the consumers of your library the need to pull it off of <code>NativeModules</code> each time. This JavaScript file also becomes a good location for you to add any JavaScript side functionality.</p>
|
||||
<p>Create a new JavaScript file named <code>ToastExample.js</code> with the content below:</p>
|
||||
<pre><code class="hljs css language-javascript"><span class="token comment">/**
|
||||
* This exposes the native ToastExample module as a JS module. This has a
|
||||
* function 'show' which takes the following parameters:
|
||||
@@ -166,6 +167,7 @@ module<span class="token punctuation">.</span>exports <span class="token operato
|
||||
|
||||
ToastExample<span class="token punctuation">.</span><span class="token function">show</span><span class="token punctuation">(</span><span class="token string">'Awesome'</span><span class="token punctuation">,</span> ToastExample<span class="token punctuation">.</span><span class="token constant">SHORT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
</code></pre>
|
||||
<p>Please make sure this JavasScript file to be the same hierarchy as <code>ToastExample.js</code>.</p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="beyond-toasts"></a><a href="#beyond-toasts" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Beyond Toasts</h2>
|
||||
<h3><a class="anchor" aria-hidden="true" id="callbacks"></a><a href="#callbacks" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Callbacks</h3>
|
||||
<p>Native modules also support a special kind of argument - a callback. In most cases it is used to provide the function call result to JavaScript.</p>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<h2><a class="anchor" aria-hidden="true" id="the-toast-module"></a><a href="#the-toast-module" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>The Toast Module</h2>
|
||||
<p>This guide will use the <a href="http://developer.android.com/reference/android/widget/Toast.html">Toast</a> example. Let's say we would like to be able to create a toast message from JavaScript.</p>
|
||||
<p>We start by creating a native module. A native module is a Java class that usually extends the <code>ReactContextBaseJavaModule</code> class and implements the functionality required by the JavaScript. Our goal here is to be able to write <code>ToastExample.show('Awesome', ToastExample.SHORT);</code> from JavaScript to display a short toast on the screen.</p>
|
||||
<p>create a new Java Class named <code>ToastModule.java</code> inside <code>android/app/src/main/java/com/your-app-name/</code> folder with the content below:</p>
|
||||
<p>Create a new Java Class named <code>ToastModule.java</code> inside <code>android/app/src/main/java/com/your-app-name/</code> folder with the content below:</p>
|
||||
<pre><code class="hljs css language-java"><span class="token comment">// ToastModule.java</span>
|
||||
|
||||
<span class="token keyword">package</span> com<span class="token punctuation">.</span>your<span class="token operator">-</span>app<span class="token operator">-</span>name<span class="token punctuation">;</span>
|
||||
@@ -150,6 +150,7 @@ R<span class="hljs-function"><span class="hljs-title">eadableArray</span> -><
|
||||
<span class="token punctuation">}</span>
|
||||
</code></pre>
|
||||
<p>To make it simpler to access your new functionality from JavaScript, it is common to wrap the native module in a JavaScript module. This is not necessary but saves the consumers of your library the need to pull it off of <code>NativeModules</code> each time. This JavaScript file also becomes a good location for you to add any JavaScript side functionality.</p>
|
||||
<p>Create a new JavaScript file named <code>ToastExample.js</code> with the content below:</p>
|
||||
<pre><code class="hljs css language-javascript"><span class="token comment">/**
|
||||
* This exposes the native ToastExample module as a JS module. This has a
|
||||
* function 'show' which takes the following parameters:
|
||||
@@ -166,6 +167,7 @@ module<span class="token punctuation">.</span>exports <span class="token operato
|
||||
|
||||
ToastExample<span class="token punctuation">.</span><span class="token function">show</span><span class="token punctuation">(</span><span class="token string">'Awesome'</span><span class="token punctuation">,</span> ToastExample<span class="token punctuation">.</span><span class="token constant">SHORT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
</code></pre>
|
||||
<p>Please make sure this JavasScript file to be the same hierarchy as <code>ToastExample.js</code>.</p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="beyond-toasts"></a><a href="#beyond-toasts" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Beyond Toasts</h2>
|
||||
<h3><a class="anchor" aria-hidden="true" id="callbacks"></a><a href="#callbacks" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Callbacks</h3>
|
||||
<p>Native modules also support a special kind of argument - a callback. In most cases it is used to provide the function call result to JavaScript.</p>
|
||||
|
||||
Reference in New Issue
Block a user