From 82f0f41b711254356cc1e35f6b67f089d5d0239d Mon Sep 17 00:00:00 2001 From: Richard Hua Date: Tue, 2 Aug 2016 17:10:23 -0700 Subject: [PATCH 1/3] Fix up `codepushify` documentation to refer to the root-level decorator --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index a2b2611..f1a60f6 100644 --- a/README.md +++ b/README.md @@ -701,14 +701,12 @@ The following sections describe the shape and behavior of these APIs in detail: ### JavaScript API Reference -When you require `react-native-code-push`, the module object provides the following top-level methods: +When you require `react-native-code-push`, the module object provides the following top-level methods in addition to the root-level [component decorator](#codepush): * [allowRestart](#codepushallowrestart): Re-allows programmatic restarts to occur as a result of an update being installed, and optionally, immediately restarts the app if a pending update had attempted to restart the app while restarts were disallowed. This is an advanced API and is only necessary if your app explicitly disallowed restarts via the `disallowRestart` method. * [checkForUpdate](#codepushcheckforupdate): Asks the CodePush service whether the configured app deployment has an update available. -* [codePushify](#codepushcodepushify): Returns a function that wraps a React component inside a "higher order" React component configured to call [`codePush.sync()`](#codepushsync) when it is mounted. This allows you to declaratively specify the behaviour of how and when your app checks for an update, downloads it and installs it. - * [disallowRestart](#codepushdisallowrestart): Temporarily disallows any programmatic restarts to occur as a result of a CodePush update being installed. This is an advanced API, and is useful when a component within your app (e.g. an onboarding process) needs to ensure that no end-user interruptions can occur during its lifetime. * [getCurrentPackage](#codepushgetcurrentpackage): Retrieves the metadata about the currently installed update (e.g. description, installation time, size). *NOTE: As of `v1.10.3-beta` of the CodePush module, this method is deprecated in favor of [`getUpdateMetadata`](#codepushgetupdatemetadata)*. From cfa437b6364e81dd506a0d2963e874a5bbb6396a Mon Sep 17 00:00:00 2001 From: Richard Hua Date: Tue, 2 Aug 2016 17:17:55 -0700 Subject: [PATCH 2/3] Use the function wrapper format instead of the decorator format for API examples --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f1a60f6..e43e3b7 100644 --- a/README.md +++ b/README.md @@ -735,16 +735,16 @@ This decorator provides support for letting you customize its behaviour to easil // Fully silent update which keeps the app in // sync with the server, without ever // interrupting the end user - @codePush() class MyApp extends Component {} + codePush()(MyApp); ``` 2. **Silent sync everytime the app resumes**. Same as 1, except we check for updates, or apply an update if one exists every time the app returns to the foreground after being "backgrounded". ```javascript // Sync for updates everytime the app resumes. - @codePush({ checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, installMode: codePush.InstallMode.ON_NEXT_RESUME }) class MyApp extends Component {} + codePush({ checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, installMode: codePush.InstallMode.ON_NEXT_RESUME })(MyApp); ``` 3. **Interactive**. When an update is available, prompt the end user for permission before downloading it, and then immediately apply the update. If an update was released using the `mandatory` flag, the end user would still be notified about the update, but they wouldn't have the choice to ignore it. @@ -753,8 +753,8 @@ This decorator provides support for letting you customize its behaviour to easil // Active update, which lets the end user know // about each update, and displays it to them // immediately after downloading it - @codePush({ updateDialog: true, installMode: codePush.InstallMode.IMMEDIATE }) class MyApp extends Component {} + codePush({ updateDialog: true, installMode: codePush.InstallMode.IMMEDIATE })(MyApp); ``` 4. **Log/display progress**. While the app is syncing with the server for updates, make use of the `codePushStatusDidChange` and/or `codePushDownloadDidProgress` event hooks to log down the different stages of this process, or even display a progress bar to the user. @@ -762,7 +762,6 @@ This decorator provides support for letting you customize its behaviour to easil ```javascript // Make use of the event hooks to keep track of // the different stages of the sync process. - @codePush() class MyApp extends Component { codePushStatusDidChange(status) { switch(syncStatus) { @@ -788,6 +787,7 @@ This decorator provides support for letting you customize its behaviour to easil console.log(progess.receivedBytes + " of " + progress.totalBytes + " received."); } } + codePush()(MyApp); ``` ##### CodePushOptions From 88d325d2a5c4f2525500fcf1d75f6755b8950b16 Mon Sep 17 00:00:00 2001 From: Richard Hua Date: Tue, 2 Aug 2016 17:30:18 -0700 Subject: [PATCH 3/3] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e43e3b7..827305b 100644 --- a/README.md +++ b/README.md @@ -722,10 +722,12 @@ When you require `react-native-code-push`, the module object provides the follow #### codePush ```javascript -codePush(options: CodePushOptions)(rootComponent: React.Component): React.Component; +codePush(options: CodePushOptions)(rootComponent: React.Component): React.Component; // Wrapper function + +@codePush(options: CodePushOptions) // Decorator; Requires ES7 support ``` -Used as a decorator to wrap a React component inside a "higher order" React component that knows how to synchronize your app's JavaScript bundle and image assets with the latest release to the configured deployment when it is mounted. Internally, the wrapper component calls [`sync`](#codepushsync) inside its `componentDidMount` lifecycle handle, which in turns performs an update check, downloads the update if it exists and installs the update for you. +Used to wrap a React component inside a "higher order" React component that knows how to synchronize your app's JavaScript bundle and image assets when it is mounted. Internally, the higher-order component calls [`sync`](#codepushsync) inside its `componentDidMount` lifecycle handle, which in turns performs an update check, downloads the update if it exists and installs the update for you. This decorator provides support for letting you customize its behaviour to easily enable apps with different requirements. Below are some examples of ways you can use it (you can pick one or even use a combination):