Skip to content

Commit

Permalink
Fix the website build
Browse files Browse the repository at this point in the history
Summary:
118e883 broke autodoc generation because autodoc isn't smart enough to understand some patterns.

I'm working around it by using the same trick as this file was using previously: reassigning the class variable.

Similarly, using a property initializer produces bad output so I had to remove it:

<img width="146" alt="screen shot 2017-02-20 at 19 00 36" src="https://cloud.githubusercontent.com/assets/810438/23138561/09ebb476-f7a0-11e6-8fad-92c5a01503c3.png">

cc ericnakagawa mkonicek for review
Closes facebook#12479

Differential Revision: D4591285

Pulled By: gaearon

fbshipit-source-id: 5884620a08874298b1b2c810e8fb769eba4e1199
  • Loading branch information
gaearon authored and Gabor Wnuk committed Feb 28, 2017
1 parent 471a9d7 commit 01bfcd2
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Libraries/AppState/AppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ const invariant = require('fbjs/lib/invariant');
* AppState is frequently used to determine the intent and proper behavior when
* handling push notifications.
*
* This module depends on the native RCTAppState module. If you don't include it,
* `AppState.isAvailable` will return `false`, and any method calls will throw.
*
* ### App States
*
* - `active` - The app is running in the foreground
Expand Down Expand Up @@ -90,11 +87,12 @@ class AppState extends NativeEventEmitter {

_eventHandlers: Object;
currentState: ?string;
isAvailable: boolean = true;
isAvailable: boolean;

constructor() {
super(RCTAppState);

this.isAvailable = true;
this._eventHandlers = {
change: new Map(),
memoryWarning: new Map(),
Expand Down Expand Up @@ -213,10 +211,13 @@ class MissingNativeAppStateShim extends EventEmitter {
}
}

// Guard against missing native module by throwing on first method call.
// Keep the API the same so Flow doesn't complain.
const appState = RCTAppState
? new AppState()
: new MissingNativeAppStateShim();
// This module depends on the native `RCTAppState` module. If you don't include it,
// `AppState.isAvailable` will return `false`, and any method calls will throw.
// We reassign the class variable to keep the autodoc generator happy.
if (RCTAppState) {
AppState = new AppState();
} else {
AppState = new MissingNativeAppStateShim();
}

module.exports = appState;
module.exports = AppState;

0 comments on commit 01bfcd2

Please sign in to comment.